Intermediate Python Programming introduction




Welcome to the intermediate Python programming tutorial series. In this series, we're going to be taking the "next steps" after one has become comfortable with the basics of Python, and has been working with it for a bit.

Up to this point, my tutorials have all been done using very basic, rudimentary Python. My definition of basic Python: code that is meant to "just make it run." This is fine for beginners, because there's not much point in overloading with nuances (most people wont retain it, since they don't care, at least I didn't when I was starting out).

I define intermediate Python code as:

  • Modular - Easily used by others and/or in other projects by you or others. Basically, write code with the intention to honor DRY (don't repeat yourself).
  • Maintainable - ...Both by the original author and by other users. Is it easily read-able and understood?
  • Scales - For this to happen, code needs to be efficient when it runs, and be able to scale. Think about reading files, working with requests, or doing calculations. Maintainability also plays a major role in scaling.

In general, code that meets the above standards in Python is done with the Object Oriented Programming (OOP) paradigm. There does exist another paradigm, called Functional Programming (FP), and there are bloody wars fought over which is better. We're going to use OOP. Either one of these is better than outright scripting, which what most beginner programmers are really doing.

To begin this series, I am going to teach a few basic standard library functions and functionalities of Python that will replace otherwise bad habits in programming, before getting into Object Oriented Programming and design.

In this introduction, I will point you towards PEP 8. PEP 8 is a guide for Python styling. Things like white spaces, indentation, naming conventions, and more. PEP 8 is a guide, not a bible.

Finally, as we go through this series, it's a good idea to keep in mind "The Zen of Python" by Tim Peters:

Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>> 

In the next tutorial, we're going to talk about string concatenation and string formatting.

The next tutorial:





  • Intermediate Python Programming introduction
  • String Concatenation and Formatting Intermediate Python Tutorial part 2
  • Argparse for CLI Intermediate Python Tutorial part 3
  • List comprehension and generator expressions Intermediate Python Tutorial part 4
  • More on list comprehension and generators Intermediate Python Tutorial part 5
  • Timeit Module Intermediate Python Tutorial part 6
  • Enumerate Intermediate Python Tutorial part 7
  • Python's Zip function
  • More on Generators with Python
  • Multiprocessing with Python intro
  • Getting Values from Multiprocessing Processes
  • Multiprocessing Spider Example
  • Introduction to Object Oriented Programming
  • Creating Environment for our Object with PyGame
  • Many Blobs - Object Oriented Programming
  • Blob Class and Modularity - Object Oriented Programming
  • Inheritance - Object Oriented Programming
  • Decorators in Python Tutorial
  • Operator Overloading Python Tutorial
  • Detecting Collisions in our Game Python Tutorial
  • Special Methods, OOP, and Iteration Python Tutorial
  • Logging Python Tutorial
  • Headless Error Handling Python Tutorial
  • __str__ and __repr_ in Python 3
  • Args and Kwargs
  • Asyncio Basics - Asynchronous programming with coroutines