Michael Driscoll's Blog, page 90
September 12, 2016
Book Contest: Win a Copy of Python 201
I have decided to sponsor a contest for my second book, Python 201: Intermediate Python. I will be giving away 3 copies of my eBook bundle (PDF, EPUB and MOBI) and 2 copies of the paperback, which I will ship anywhere in the world. If you haven’t heard of my book, you may want to read about it here.
How You Can Win
To win your copy of this book, all you need to do is come up with a comment below highlighting the reason “why you would like to win this book”.
Duration of the contest & selection of winners
The contest is valid until Friday, Sept 16th at 11:59 p.m. CST, and is open to everyone. Winners will be selected on the basis of their comment posted. The contest will close on 09/17/2016 at 12 a.m. CST.
PyDev of the Week: Rami Chowdhury
This week we welcome Rami Chowdhury (@necaris) as our PyDev of the Week! Rami is an active contributor to the Python community and an organization for the North American PyCon. If you’d like to see what he’s up to, you might want to check out his website which has links to the various open source repositories that he contributes to. Let’s take a few moments to get to know him better!
Can you tell us a little about yourself (hobbies, education, etc):
I was always interested in and a pretty fearless user of computers when I was younger, but I went to college to study political science and economics (in the UK) and only stumbled into programming then. It felt a bit like I’d found my calling. In my spare time I’m making a concerted effort _not_ to write more code, and I’ve taken up knitting as a way to occupy my hands. I also enjoy reading, wandering the museums of my hometown (Washington DC), and playing with my dachshund Wesley.
Why did you start using Python?
I was writing Perl CGI scripts for my college’s limited web-hosting service when I came across Eric Raymond’s “Why Python” essay — which sparked my interest. I started using it for its broad and useful standard library, the readability of the documentation (and resulting code), and because it was already installed on the Linux machines available to me.
What other programming languages do you know and which is your favorite?
As a full-stack web developer I’m fluent in Python and Javascript (and dialects thereof), but I’m also somewhat familiar with PHP, Clojure, Java, Erlang, C, and Go. I read something recent about programming languages and language communities being cultures and subcultures in their own right, and Python remains my favorite not just because I can use it for pretty much everything, but also because I enjoy being a member of that culture.
What projects are you working on now?
I’m lucky enough to work mostly in Python, so outside of work I’m playing with projects that allow me to learn new languages and technologies — one web-based app that’s letting me play with Elm and aiohttp, and a file format parser that’s helping me teach myself Rust.
Which Python libraries are your favorite (core or 3rd party)?
Core: __future__
September 8, 2016
wxPython Cookbook Cover Story
I always spend some time thinking about how I want my book’s cover to look. When I was designing the Cookbook’s cover, I thought mostly about food and chefs. I had originally thought I might have some kind of kitchen scene with mice in chef hats and a snake on the mantle. But I wanted to take the idea of cooking and put a twist on it.
Instead of a kitchen, I thought of cowboys herding cattle and how they usually had a cook with them. So I went with that idea, although I didn’t have the herds of animals added to the cover.
To help differentiate the Cookbook from my previous works, I hired a different artist from my previous titles named Liza Tretyakova. You can check out some of her work on Behance or even contact her directly by email (schimmel@inbox.ru) if you happen to need a great artist.
I thought it might be fun for you to see how the cover art evolved as I worked with the artist to get my ideas for the cover turned into reality. Let’s start with the first sketch I got from Liza:
This sketch impressed me quite a bit as my previous artists always gave me much rougher sketches to look at. The next step was to add a touch of color to the cover:
At this point, I hadn’t really thought too much about making each mouse unique in its coloring. Liza suggested that idea and I agreed. The next to last step was to add almost full color to the cover:
This looked really good so I approved it and Liza finished the cover. As you’ve probably already seen, it looks like this:
This whole process took Liza and I about a week and a half. I think it turned out quite well!
Be sure to check out the Kickstarter if you’d like to support this book or you’d like to get a good deal on my previous titles.
September 6, 2016
Python 201 is Officially Published!
My second book, Python 201: Intermediate Python (ISBN: 978-0-9960628-3-1), is now finished and officially published. You can check it out at the following locations:
You can get a paperback copy through Lulu
It is available as a PDF, mobi and epub via Gumroad and Leanpub
Amazon Kindle
The paperback will become available on Amazon and other online retailers later this week or month depending on how long it takes Lulu to get it pushed out. I am also working on creating an iBook version for iTunes, but that isn’t complete at this time.
September 5, 2016
PyDev of the Week: Reinout van Rees
This week we welcome Reinout van Rees (@reinoutvanrees) as our PyDev of the Week! Reinout is the creator / maintainer of zest.releaser. He has a nice website that includes a Python blog that you might want to check out. I would also recommend checking his Github page to see what projects he’s a part of.
Why did you start using Python?
I’m from the Netherlands, which of course gives you a slight advantage when programming Python. By education, I’m a civil engineer. I *did* take all the available programming classes, but most of it was of course traffic engineering, construction calculation and water engineering and so on.
In 2000 I ended up in a EU research project at the end of my study which was basically a mix between civil engineering and internet programming. Just what I needed. I used some Java libraries to do XML processing (which was hip at that time), but couldn’t get something to work in time for an important demo.
So… I tried out Jython. Calling Java code with a Java Python interpreter was way easier and I got the demo finished in time. So *I started using Python by necessity and because I accidentally tripped over it*.
After discovering Python halfway 2000 I started using it more and more during my PhD work. Zope got popular then. I visited many of the early Europython conferences. I started using Plone quite soon. And when I had to find a real job after my PhD I quite by accident ended up at a Plone company, doing real programming for money.
What other programming languages do you know and which is your favorite?
Well, Python is by far the language I used most. I used to know Pascal quite well. Turbo Pascal 6 and later Delphi 1. If you call XSLT 1.0 a programming language: I’ve used that for two years. A bit of Bash, of course. A bit of Javascript.
A favourite? I haven’t programmed it in ages and I never did much with it and it is terribly unreadable and I only wrote one useful program with it, but…. APL! “A Programming Language”. Keywords in that language are dots, slashes, greek letters and weird symbols. If I remember correctly, something like “+/A” would return the sum of vector A. I probably have the syntax wrong. But I sure had some fun with that 3.5″ floppy disk with a demo copy of IBM APL 2.0!
What projects are you working on now?
Since 2010 I work for…. a civil engineering firm (2/3 of the company are water experts) that does a lot of Python/Django programming (1/3 of the company are programmers). That’s an impossible perfect combination for me as a civil engineer who became a programmer. Especially as it is only 30 minutes cycling from my home. Pure bliss.
Well, work? At the moment mostly behind-the-scenes work. Setting up a new Jenkins instance, figuring out how we should use Docker, writing automatic monitoring tools, zabbix integration, mentoring new programmers, some sysadmin stuff, updating buildout recipes for python 3, re-building our central login site, etc.
So everything from hard thinking on a docker strategy to simply having fun with a quick monitoring script. And keeping track of what happens with Python packaging and Django.
Which Python libraries are your favorite (core or 3rd party)?
Let me mention one of my own first. zest.releaser. I started it already in 2008. And I still use it every time I make a release of some Python package: it updates the version number, records the release date in the changelog, tags it and optionally uploads it to pypi. All those things I’m too lazy to do by hand. And many others like and use it, too. That’s a fun open source project to maintain, especially as my brother is the co-maintainer.
A nice core Python library? I always appreciate “tempfile“. Always handy to create a tempfile or a temporary directory in a safe way. I use it quite a lot. It simply does what you need it to do.
Is there anything else you’d like to say?
Well, I didn’t talk about my hobbies yet. I skipped that in the first question because I was too busy talking about Python
August 29, 2016
wxPython Cookbook Sample Chapters
My newest book will be my own home brewed version of a wxPython Cookbook. If you’re interested in learning more about it, then please check out the Kickstarter campaign. The brief synopsis is that it will have a little over 50 recipes in the book and around 300 pages of content.
To help you make an informed decision about whether or not you would like to support the book, I am releasing a few sample chapters. You can download them here as a PDF. Please note that these chapters are in a beta state. I will be updating the vast majority of the book with new screenshots and updated code examples where appropriate as well as various other tweaks and enhancements.
PyDev of the Week: Damien George
This week we welcome Damien George as our PyDev of the Week! Damien is the man behind the MicroPython project which allows you to run a version of Python on microcontrollers. You can learn more about Damien on his website or by visiting his Github page. Let’s spend some time getting to know our fellow Pythonista better!
Can you tell us a little about yourself (hobbies, education, etc):
I grew up in Melbourne, Australia and started playing with computers and electronics pretty early on. I had a Commodore 64 when I was young and remember borrowing books from the local library on how to program it in assembler. Really it just gave you a bunch of “data” statements to type in, but in the end you could make some pretty cool stuff. In high school I liked physics and maths and then I went to university and did degrees in both science and engineering. I majored in physics and computer engineering and then did a PhD in physics, after which I moved to the Netherlands, and eventually the UK, to do research in theoretical high-energy physics (extra dimensions, supersymmetry, cosmology, things like that). During my career as a physicist I kept an active interest in programming and robotics, with lots of side projects including a self-made CNC machine (see http://dpgeorge.net/cnc/).
Why did you start using Python?
Because I needed a language that was both powerful and allowed very fast development. I think the first big project that I used Python for was the Paperscape website that I developed with a colleague, which visualises scientific papers in physics (see http://paperscape.org). Python is used extensively in the back end to parse TeX, LaTeX and PDF files and extract citation information, as well as maintain an SQL database of the papers.
What other programming languages do you know and which is your favorite?
I’ve used a lot of languages over the years, including: assembler of many architectures, BASIC, Fortran (mostly 77), C, C++, Java, Haskell, Go and JavaScript. I like C a lot and would say it’s my favourite, but C++ is also good and now a much nicer language with the modern standards. I like Haskell but don’t use it for anything serious.
What projects are you working on now?
I spend pretty much all of my time developing MicroPython (see https://micropython.org and https://github.com/micropython/micropython). There are a lot of features I’d like to add, optimisations to make, and new platforms to get it running on. Right now I’m concentrating on making MicroPython run well on the ESP8266 Wi-Fi chip, as part of the Kickstarter that we ran earlier this year. That involves programming as well as documentation, tutorials and forum management. I’m also helping to develop the BBC micro:bit port of MicroPython (see https://github.com/bbcmicrobit/micropython). A lot of people contribute to the MicroPython project, in many different ways, which is fantastic and helps the project grow. I look forward to seeing MicroPython grow bigger and be used in new and interesting ways.
Which Python libraries are your favorite (core or 3rd party)?
Because of their special need in MicroPython I like the boring libraries like sys, os and struct. But a more interesting one is our “machine” module which abstracts lower level hardware in a Pythonic way. For example GPIO pins, I2C busses, analog to digital convertors, and so on. On the BBC micro:bit there is a “microbit” module which has a lot of fun things in it to allow children to easily program the device.
Where do you see Python going as a programming language?
Python evolves and keeps up with the needs of programmers as well as current technology, and that’s a really important thing that I think will allow it to stay as one of the top 5 programming languages for a long time to come. There will always be the need for different languages, each specialising to certain needs, and Python will remain an excellent choice for general purpose rapid-development programming.
Is there anything else you’d like to say?
I think the Python community is amazing. It’s friendly and open and there are a lot of smart people who dedicate their time to making Python not only a great language but also a great programming-ecosystem. More broadly I think that the open source community and open source software is nowadays a fundamental part of software and computing and I’m really happy to be able to contribute to it.
Thanks for doing the interview!
August 23, 2016
Python 201 Releasing in 2 Weeks!
My second book, Python 201: Intermediate Python is releasing two weeks from today on September 6th, 2016. I just wanted to remind anyone who is interested that you can pre-order a signed paperback copy of the book here right up until release day. You will also receive a copy of the book in the following digital formats: PDF, EPUB and MOBI (Kindle format).
My book is also available for early release digitally on Gumroad and Leanpub.
Check out either of those links for more information!
August 22, 2016
ANN: The wxPython Cookbook Kickstarter
Several years ago, the readers of this blog asked me to take some of my articles and turn them into a cookbook on wxPython. I have finally decided to do just that. I am including over 50 recipes that I am currently editing to make them more consistent and updating them to be compatible with the latest versions of wxPython. I currently have nearly 300 pages of content!
To help fund the initial production of the book, I am doing a fun little Kickstarter campaign for the project. The money raised will be used for the unique perks offered in the campaign as well as various production costs related to the book, such as ISBN acquisition, artwork, software expenses, advertising, etc.
In case you don’t know what wxPython is, the wxPython package is a popular toolkit for creating cross platform desktop user interfaces. It works on Windows, Mac and Linux with little to no modification of your code base.
The examples in my book will work with both wxPython 3.0.2 Classic as well as wxPython Phoenix, which is the bleeding edge of wxPython that supports Python 3. If I discover any recipes that do not work with Phoenix, they will be clearly marked or there will be an alternative example given that does work.
Here is a listing of the current set of recipes in no particular order:
Adding / Removing Widgets Dynamically
How to put a background image on a panel
Binding Multiple Widgets to the Same Handler
Catching Exceptions from Anywhere
wxPython’s Context Managers
Converting wx.DateTime to Python datetime
Creating an About Box
How to Create a Login Dialog
How to Create a “Dark Mode”
Generating a Dialog from a Config File
How to Disable a Wizard’s Next Button
How to Use Drag and Drop
How to Drag and Drop a File From Your App to the OS
How to Edit Your GUI Interactively Using reload()
How to Embed an Image in the Title Bar
Extracting XML from the RichTextCtrl
How to Fade-in a Frame / Dialog
How to Fire Multiple Event Handlers
Making your Frame Maximize or Full Screen
Using wx.Frame Styles
Get the Event Name Instead of an Integer
How to Get Children Widgets from a Sizer
How to Use the Clipboard
Catching Key and Char Events
Learning How Focus Works in wxPython
Making Your Text Flash
Minimizing to System Tray
Using ObjectListView instead of ListCtrl
Making a Panel Self-Destruct
How to Switch Between Panels
wxPython: Using PyDispatcher instead of Pubsub
Creating Graphs with PyPlot
Redirect Python’s Logging Module to a TextCtrl
Redirecting stdout / stderr
Resetting the Background Color
Saving Data to a Config File
How to Take a Screenshot of Your wxPython App and Print it
Creating a Simple Notebook
Ensuring Only One Instance Per Frame
Storing Objects in ComboBox or ListBox Widgets
Syncing Scrolling Between Two Grids
Creating Taskbar Icons
A wx.Timer Tutorial
How to Update a Progress Bar from a Thread
Updating Your Application with Esky
Creating a URL Shortener
Using Threads in wxPython
How to Create a Grid in XRC
An Introduction to XRC
Note: Recipe names and order are subject to change
PyDev of the Week: Michele Simionato
This week we welcome Michele Simionato as our PyDev of the Week! Michele is an expert on Python and is known for his paper on Python’s Method Resolution Order which was published to the Python website by Guide Van Rossum and for a very interesting series of articles on metaclasses that he wrote with David Mertz. They are a bit difficult to find, but you can read the first one of the 3-part series here. He is one of the founders of the Italian Python Association. Michele has a Ph. D. about the Renormalization of Quantum Field Theory. Let’s take a few moments
Can you tell us a little about yourself (hobbies, education, etc):
I originally come from academia and I have a Ph. D. in Theoretical Physics. Then I worked for several years for an Analytics firm (stock market risk assessment) and now I am back to science, doing earthquake simulations at GEM.
Why did you start using Python?
It happened in 2002. At the time I was a postdoc researcher in the department of Physics and Astronomy at Pittsburgh University. I decided that it was time to learn some modern programming language, in view of a possible career outside academia. After reading a couple of long books by Bruce Eckel, first about C++ and then about Java, I decided that I did not want to program in either of them. I was in doubt between Ruby and Python, but Python won because of the better scientific libraries and of the more pragmatic philosophy.
What other programming languages do you know and which is your favorite?
A long time ago I started with Basic and Pascal and later on I worked a lot with Mathematica and Maple. After learning Python I become interested in functional languages and I know decently well Scheme, so much that I nearly wrote a book on it, The Adventures of a Pythonista in Schemeland. In my daily job I had to work a lot with SQL (which I like enough) and with Javascript (which I don’t like).
What projects are you working on now?
In the last three years I have become the maintainer and the main developer of the OpenQuake Engine, which is a computational engine to produce earthquake hazard and risk assessment. It means that after several years of being a database and Web developer I have become a scientific programmer and now I spend most of my time doing performance analysis of massive distributed calculations. I also keep a blog where I document my fighting with the engine.
Which Python libraries are your favorite (core or 3rd party)?
numpy is a really well thought library, an essential tool for people doing scientific applications.
Where do you see Python going as a programming language?
Honestly, I am unsure about where Python as a language in going, and I am not even convinced I like the recent trend. Certainly I would like for the language to become simpler, that’s what attracted me to Python in the first place, and instead I see several things that are becoming increasingly complicated. Also, there are now other languages out there that are worth of note, whereas for years Python had no competitors. If you want to know, I am thinking about Go for server side programming and about Julia for scientific programming. Both of them looks really interesting even if I have not programmed in either of them. Python should not rest thinking that it is best than Java and C++ (an easy win) and instead consider seriously the new contenders.
What is your take on the current market for Python programmers?
It has always been a good market for Python programmers (at least from when I started, 14 years ago) and now it is even more so. I get offers for Python jobs nearly every week.
Is there anything else you’d like to say?
My tagline at the coming EuroPython conference will be “Legacy code warrior”: that reflects my daily job in the last 10 years at least. See you in Bilbao!
Thanks for doing the interview!