Learning Python 5th edition — Reading notes

Chapter 1 A Python Q&A Session


  • Software quality, object-oriented
  • Developer productivity
  • Program portability
  • Support libraries
  • Component integration
  • Enjoyment XD
  • not only a Scripting Language


  • execution speed: not fully compiled

Fun notes:

  • try import this

Chapter 2 How Python Runs Programs

Python as an interpreter: a layer of software logic between code and
computer hardware.

Source m.py -> Byte code m.pyc -> Runtime in python virtual machine(PVM)

Note that Python byte code is not binary machine code (instructions for an
Intel or ARM chip). Byte code is a Python-specific representation. That is
why some python code may not run as fast as C/C++.

Chapter 3 How You Run Programs

hash bang / shebang

tell the system where the python interpreter is, use sys.executable to find location.


or set the environment like:

#!/usr/bin/env python3

How to run programs

Just simply

python3 script

or change executable privileges with chmod +x and


Import and Reload

import script

Note that after the first import, later imports do nothing. If you want to run
the import again, use reload:

from imp import reload


Note the differences between import X and from X import Y.

import X


from X import Y