Mozilla Announces Pyodide – Python in the Browser

Mozilla announced a new project called Pyodide earlier this week. The aim of Pyodide is to bring Python’s scientific stack into the browser.

The Pyodide project will give you a full, standard Python interpreter that runs in your browser and also give you access to the browsers Web APIs. Currently, Pyodide does not support threading or networking sockets. Python is also quite a bit slower to run in the browser, although it is usable for interactive exploration.

The article mentions other projects, such as Brython and Skulpt. These projects are rewrites of Python’s interpreter in Javascript. Their disadvantage to Pyodide is that they cannot use Python extensions that were written in C, such as Numpy or Pandas. Pyodide overcomes this issue.

Anyway, this sounds like a really interesting project. I always thought the demos I used to see of Python running in Silverlight in the browser were cool. That project is basically dead at this point, but Pyodide sounds like a really interesting new hack at getting Python into the browser. Hopefully it will go somewhere.

Creating a GUI Application for NASA’s API with wxPython

Growing up, I have always found the universe and space in general to be exciting. It is fun to dream about what worlds remain unexplored. I also enjoy seeing photos from other worlds or thinking about the vastness of space. What does this have to do with Python though? Well, the National Aeronautics and Space Administration (NASA) has a web API that allows you to search their image library.

You can read all about it on their website.

The NASA website recommends getting an Application Programming Interface (API) key. If you go to that website, the form that you will fill out is nice and short.

Technically, you do not need an API key to make requests against NASA’s services. However they do have rate limiting in place for developers who access their site without an API key. Even with a key, you are limited to a default of 1000 requests per hour. If you go over your allocation, you will be temporarily blocked from making requests. You can contact NASA to request a higher rate limit though.

Interestingly, the documentation doesn’t really say how many requests you can make without an API key.

The API documentation disagrees with NASA’s Image API documentation about which endpoints to hit, which makes working with their website a bit confusing.

For example, you will see the API documentation talking about this URL:

  • https://api.nasa.gov/planetary/apod?api_key=API_KEY_GOES_HERE

But in the Image API documentation, the API root is:

  • https://images-api.nasa.gov

For the purposes of this tutorial, you will be using the latter. Continue reading Creating a GUI Application for NASA’s API with wxPython

PyDev of the Week: Pierre Denis

This week we welcome Pierre Denis as our PyDev of the Week! Pierre is the creator of Lea, a probabilistic programming package in Python. He can be found on LinkedIn where you can see his CV and learn more about some of the things he is up to. Let’s take a few moments to get to know Pierre better!

Can you tell us a little about yourself (hobbies, education, etc):

I’ve a Master in Computer Science from UCL Louvain-la-Neuve, Belgium, where I reside. I’m working since 20 years as software engineer in [Spacebel](http://www.spacebel.be), a company developing systems for Space. Basically, I like everything creative and elegant. Beside arts, music, literature, I ‘m looking for this in physics, algorithmic, GUI and mathematics. I love programming, especially in Python. So far, I have initiated three open-source Python projects: UFOPAX (textual virtual universe), Unum (quantities with unit consistency) and Lea (probabilistic programming). For these developments, I tend to be perfectionist and consequently slow: I’m the kind of guy that re-write the same program ten times, just for the sake of inner beauty!

Beside programming, I’m doing research in number theory (twin primes conjecture). Also, I’m writing short stories in French, my mother tongue, with some reference to the ‘Pataphysics of Alfred Jarry and a lot of nonsense. Incidentally and fortunately, programs can be good for producing nonsense, as I showed in my bullshit generator! Continue reading PyDev of the Week: Pierre Denis

Python Used to Take Photo of Black Hole

Scientists have used a new algorithm to take a photo of a black hole. One of the most exciting parts about it to me is that they used a lot of Python libraries to do the magic.

Here’s a list mentioned in their paper:

They also used their own custom Python code which is available on Github

If you’re interested in a more laymen’s explanation of the ideas behind taking the photo, there’s a nice TED talk on it from one of the researchers:


Related Links

ReportLab: Adding a Chart to a PDF with Python

The ReportLab toolkit supports adding many different charts and graphs to your PDFs. In fact, I have covered some of them in a previous article. However most of the examples I have seen, including the ones in my own article, do not show how to insert a chart as a Flowable.

What that means is that most examples show you how to create a PDF with a single page that contains the chart in it. Most developers would want to be able to create some text, perhaps a table and insert the chart along with those elements. You would also usually have additional text following the chart.

For this article, you will learn how to do just that. Continue reading ReportLab: Adding a Chart to a PDF with Python

PyDev of the Week: Abdur-Rahmaan Janhangeer

This week we welcome Abdur-Rahmaan Janhangeer as our PyDev of the Week! Abdur-Rahmaan is the French translator of Think Python. You can see what he is up to on his blog as well as on Github. Let’s take a few moments to get to know him better!

Can you tell us a little about yourself (hobbies, education, etc):

I’m Abdur-Rahmaan Janhangeer from Mauritius, a paradise island in the Indian Ocean and currently one of the best tourist destinations. I have an IT business and i am shyly becoming a Python Trainer.

I am mostly self-taught in programming. Concerning Python, I’m the Arabic Coordinator for the Python docs, translator of Think Python into French (publishing soon) and organising member for the py user-group of Mauritius. I also did some really tiny contributions to LinuxMint, Numpy and Odoo.

As “hobby”, i like to dig into Compiler Theory and code some toy langs in my spare time. Being a gallery moderator, I use InkScape to design logos and business cards for people. Playing around with graphics! Continue reading PyDev of the Week: Abdur-Rahmaan Janhangeer

Product Review: Python Flash Cards

No Starch Press is best known for creating books on computer programming. However they recently released a new product called Python Flash Cards by Eric Matthes, the author of Python Crash Course. I thought this was a unique product and decided to ask for a review copy.

The cards and their box are high quality. I like the card stock they used quite a bit. The cards themselves target Python 3.7. Continue reading Product Review: Python Flash Cards

My Cover Story for Creating GUI Applications with wxPython Book

I thought it would be fun to write a bit about the cover art for my new book, Creating GUI Applications with wxPython. I had meant to post about that during the actual Kickstarter campaign.

My original idea for the cover was to have the mouse directing a Phoenix to attack a snake. The Phoenix is a reference to the code name for wxPython 4 before it was released and you can still see references to Phoenix in the documentation and the artwork on some of the pages for the wxPython project.

In fact, I commissioned that cover to be done. Here’s a sketch of it:

Original cover concept art

As you can see, the artist had trouble remembering that the snake should be a Python. He continued to make lazy mistakes in the finished product and I ended up scrapping that cover. I am not sure if I will use that cover for a future book or not. I personally like the look of the mouse and Phoenix, but the Python will always bother me. Continue reading My Cover Story for Creating GUI Applications with wxPython Book

PyDev of the Week: Kyle Stratis

This week we welcome Kyle Stratis (@KyleStratis) as our PyDev of the Week! He is an active contributor at Real Python but also maintains his own website. You can catch up with his projects on Github as well. Let’s take a few moments to get to know Kyle!

Can you tell us a little about yourself (hobbies, education, etc):

I’m a self-taught developer, I actually studied neuroscience up through graduate school, with a focus on mechanisms of attention in the auditory system. The coding I had to do at every step of the experimental process rekindled my early love of the craft, and a good friend stepped in as a mentor – so I taught myself and got my first job while I was writing my master’s thesis.

While I do a lot of programming on the side, I also enjoy weightlifting (my father was a bodybuilder and gym-owner, with 4x Mr. Olympia Jay Cutler starting at his gym, so maybe it’s genetic), skateboarding, and surfing, which I do noticeably less of now that I live in Boston. I’m also a bit of a metalhead, so on any given weekend you’ll be likely to find me at a dingy club with a battlevest on and cheap beer in hand. I’d be remiss to not mention spending time with my wife, which usually is spent reading, hiking, and playing with our 2 cats. Continue reading PyDev of the Week: Kyle Stratis

wxPython 4 and PubSub

The Publish-Subscribe pattern is pretty common in computer science and very useful too. The wxPython GUI toolkit has had an implementation of it for a very long time in wx.lib.pubsub. This implementation is based on the PyPubSub package. While you could always download PyPubSub and use it directly instead, it was nice to be able to just run wxPython without an additional dependency.

However, as of wxPython 4.0.4, wx.lib.pubsub is now deprecated and will be removed in a future version of wxPython. So now you will need to download PyPubSub or PyDispatcher if you want to use the Publish-Subscribe pattern easily in wxPython.


Installing PyPubSub

You can install PyPubSub using pip.

Here’s how to do it:

pip install pypubsub

PyPubSub should install quite quickly. Once it’s done, let’s find out how to use it! Continue reading wxPython 4 and PubSub