Further Reading: Intermediate Python Resources

So after reading one of my Python books (available free online here and here), you're no longer a complete beginner and would like to know where to go next. It can be hard to find intermediate-level material: stuff that isn't for total beginners or advanced computer scientists. The topics that you should google for are Python standard library, Python object oriented programming, Python idioms, and popular Python modules.

For a more concrete list of resources, here's my list of recommendations.

Continuing with Python

  • The Python Module of the Week Blog covers many of the modules in Python's standard library with practical examples. The Python standard library has a wide range of handy functions ("Guido's Time Machine" refers to how requests for features in Python would often be met by Guido van Rosum mentioning he had added it the night before.)
  • Python Pocket Reference is a short book intended for programmers who want to learn Python quickly. Now that you know basic programming concepts, this short book is a great way to fill out your Python knowledge and explore some more modules without spending a lot of time.
  • Python 3 Object-oriented Programming is a great resource to learn specifically about classes, objects, and other OOP concepts. My books skip OOP since it isn't necessary to get started coding, but once you've been programming for a while it's a must to become familiar with these topics.
  • Data science and machine learning are hot topics in the job market. Data Science from Scratch and Programming Collective Intelligence are both great introductions to these topics.
  • If you'd like to learn Python well enough to become a software engineer, Effective Python: 59 Specific Ways to Write Better Python provides a nice list of advanced (but effective) topics to read up on.
  • The Python Cookbook has several recipes for getting stuff done in Python. Reformatting text to fixed columns, determining last Friday's date, or using callback functions are all things that are possible with Python, but you don't want to waste time figuring out how to do them on your own.
  • The Hitchhiker's Guide to Python is a brilliant summary of many Python gotchas and idioms specific to the Python language.
  • Problem Solving with Algorithms and Data Structures Using Python is a good computer science textbook to exploring algorithms in a direct, readable text. It's free to read online.

Practicing Your Code-Fu

Moving On to Other Languages

Python is versatile and you can keep going down that path if you choose, but don't feel that you're somehow "not ready" to tackle a new language. If you do want to move on, here's some resources for the next step.

  • JavaScript: All dynamic behavior that happens in the browser is from JavaScript code. If you want to learn to create web apps, getting a basic understanding of HTML and CSS is recommended. The jQuery module is also standard for doing any web app development. My favorite JavaScript books are: Eloquent JavaScript (free), JavaScript and JQuery: Interactive Front-End Web Development, and (once you have some JS experience) Crockford's JavaScript: The Good Parts is the key book to read to understand the language.
  • Ruby: Ruby is a scripting language and similar to Python. It's noteworthy for the Ruby on Rails web app framework. You can try it out online at tryruby.org, and Codecademy has tracks for both Ruby and Ruby on Rails. But since you already know how to code, I'd suggest the Learn Ruby in 20 Minutes page on the official Ruby site.
  • Java or C#: These languages are fairly similar to each other. Java is the more popular one and a mainstay of software engineering jobs. C# is (essentially) Microsoft's version of Java, meant to create Windows applications. I don't have any recommendations as far as C# books, but Java: A Beginner's Guide is a decent intro. There have been plenty of slight changes to the Java language over the years, so you don't want to get a book that's more than a decade old or so.
  • Read More

    Celebrating the Release of "Automate the Boring Stuff with Python" with Discount Codes!

    UPDATE: The promo period is over. These discount codes are no longer valid.

    My latest book, "Automate the Boring Stuff with Python" is being released on Saturday, the 25th! This is a Python programming book for complete beginners who want to learn to code using practical projects. Automate the Boring Stuff with Python will be available online under a Creative Commons license as well, making it accessible to all. (I'm working furiously to finish formatting the HTML version right now! It will be posted to AutomateTheBoringStuff.com)

    No Starch Press has the 30% discount code PYBUTLER that you can use to order the book off their site. You'll get an Early Access copy now (the first 12 chapters) and then the full book on the 25th the full ebook immediately.

    In addition, I've also added 70% discount codes for my other books! These are the max discounts I can give (I don't receive royalties for these sales). Thanks so much to all my readers, I never imagined six years ago when I started writing that I would be here now. :D

    Invent Your Own Computer Games with Python, 3rd Edition FAM5M2RM (Read online, download PDF or ebook)

    Making Games with Python & Pygame 2A5GKQRE (Read online, download PDF or ebook)

    Hacking Secret Ciphers with Python MRLEG3A7 (Read online, download PDF or ebook)

    These discount codes will work for the next few days.

    Read More

    3rd Edition Released

    Download the PDF

    The 3rd edition of "Invent Your Own Computer Games with Python" is now available. The 3rd edition has been streamlined to provide the same content but in 50 fewer pages, making it an easier read. If you've already read the 2nd edition, there's no need to read the 3rd (unless you want to sharpen your Python skills). But for new readers, Invent with Python should be even easier to pick up.

    Buy the 3rd Edition on Amazon

    Read the 3rd Edition online for free

    Read the 2nd Edition

    The 3rd edition is also being used for the translations. Currently the Spanish translation is online (though incomplete). The German and Dutch versions are nearing completion as well.

    Read More

    Translate Your Python 3 Program with the gettext Module

    You've written a Python 3 program and want to make it available in other languages. You could duplicate the entire code-base, then go painstakingly through each .py file and replace any text strings you find. But this would mean you have two separate copies of your code, which doubles your workload every time you need to make a change or fix a bug. And if you want your program in other languages, it gets even worse.

    Fortunately, Python provides a solution with the gettext module.


    Read More

    Programming a Bot to Play the "Sushi Go Round" Flash Game

    Update 2015/01/08: If you attended my NCSS class on making a bot for this game, you can download the sushi.zip file which has all the code in bot5.py. Feel free to send questions to me at [email protected] or tweet at me: @AlSweigart

    This tutorial teaches how to write a bot that can automatically play the Flash game Sushi Go Round. The concepts in this tutorial can be applied to make bots that play other games as well. It's inspired by the How to Build a Python Bot That Can Play Web Games by Chris Kiehl. The primary improvement of this tutorial is it uses the cross-platform PyAutoGUI module to control the mouse and take screenshots. It is documented on its ReadTheDocs page.

    Sushi Go Round is a resource management game similar to "Dine N Dash". You fill customer orders for different types of sushi and place them on the conveyor belt. Incoming customers may take other customer's sushi orders, forcing you to remake orders. Customers who wait too long to get orders end up leaving, costing you reputation. Angry customers can be placated with saki, but this bot does not make use of that feature. Ingredients will have to be ordered as they get low.

    I've refined this bot so that it can successfully play all the way through the game, ending up with a score of about 38,000. The top scores are a little over 100,000, so there is still room for improvement with this bot. You can watch a YouTube video of the bot playing.

    The source code and images for the bot can be downloaded here or viewed on GitHub.


    Read More

    Making a Text Adventure Game with the cmd and textwrap Python Modules

    Text adventures are an old game genre where the entire world is textually described as a series of rooms. Play involves entering simple text commands such as "move north" or "eat pie". Each room in the game world has its own text description, items on the ground, and exits to adjacent rooms. "Room" is a general name for a single area in the game world: a room can be a large open canyon or the inside of a wardrobe. Multi-user text adventures, called MUDs or Multi-User Dungeons, were the precursor to modern MMORPGs. You can still play MUDs today by finding them on The Mud Connector.

    Screenshot of an old text adventure game.

    Text adventures are easyto make because they don't require graphics. This tutorial uses two Python modules, cmd and textwrap and makes minimal use of object-oriented programming, but you don't have to know OOP concepts to follow. (But in general, text adventures would do very well with an object-oriented approach.) This tutorial is for beginner Python 3 programmers.

    The code for Text Adventure Demo is available on GitHub.


    Read More