Before diving into the project I decided to take a look at a few Python video lectures to learn language idioms and features which I might have not heard of.
Finding Python video lectures was pretty easy as I run a free video lecture blog.
First Python Lecture: Python for Programmers
Interesting moments in the lecture:
- [07:15] There are several Python implementations - CPython, PyPy, IronPython and Jython.
- Python has similarities with [12:04] Java, [15:30] C++ and [19:05] C programming languages.
- [15:37] Python is multi-paradigm language supporting object oriented, procedural, generic and functional programming paradigms.
- [19:49] Python follows C standard's rationale: 1. trust the programmer; 2. don't prevent the programmer from doing what needs to be done; 3. keep the language small and simple; 4. provide only one way to do an operation.
- [13:02] Python code is normally implicitly compiled to bytecode.
- [13:25] Everything inherits from object.
- [14:56] Garbage collection in classic Python happens as soon as possible.
- [24:50] Python has strong but dynamic typing.
- [28:42] Names don't have types, objects do.
- [36:25] Why are there two ways to raise a number to a power (with double star ** operator and pow())? - Because pow() is a three argument function pow(x, y, z) which does x^y mod z.
- [36:52] Python supports plain and Unicode strings.
- [38:40] Python provides several built-in container types: tuple's, list's, set's, frozenset's and dict's.
- [41:55] c[i:j:k] does slicing with step k.
- [42:45] c[i:j] always has first bound included and last bound excluded.
- [44:11] Comparisons can be "chained", for example 3 < x < 9.
- [45:05] False values in Python are 0, "", None, empty containers and False.
- [49:07] 'for' is implemented in terms of iterators.
- [52:18] Function parameters may end with *name to take a tuple of arbitrary arguments, or may end with **name to take a dict of arbitrary arguments.
- [55:39] Generators.
- [01:00:20] Closures.
- [01:02:00] Classes.
- [01:05:30] Subclassing.
- [01:07:00] Properties.
- [01:14:35] Importing modules.
- [01:16:20] Every Python source file is a module, and you can just import it.
- [01:17:20] Packages.
Okay, this talk was a very basic talk and it really was an introduction for someone who never worked in Python. I could not find many interesting points to point out from the lecture, so the last 8 points are just titles of topics covered in the lecture.
Second Python Lecture: Advanced Python or Understanding Python
Interesting moments in the lecture:
- [03:18] Python is designed by implementation.
- [04:20] Everything is runtime (even compiletime is runtime).
- [04:42] A namespace is a dict.
- [05:33] A function is created by having its code compiled to code object, then wrapped as a function object.
- [10:00] Everything is an object and a reference, except variables.
- [11:00] Python has 3-scopes rule - names are either local, global or builtin.
- [11:12] Global names mean they exist in a module, not everywhere!
- [14:02] 'import mod' statement is just a syntactic sugar for mod = __import__("mod").
- [14:15] sys.modules contains a list of cached modules.
- [14:30] You may set the value of a module name in sys.modules dict to None, to make it unimportable.
- [15:20] Mutable objects are not hashable, most immutable objects are hashable.
- [18:05] Assignments, type checks, identity comparison, 'and or not', method calls are not object hooks.
- [22:15] Any Python object has two special attributes __dict__ which holds per object data and __class__ which refers to the class.
- [27:18] Iterators are not rewindable, reversible or copyable.
- [29:04] Functions with yield return generators.
- [39:20] "New" style classes unified C types and Python classes.
- [47:00] __slots__ prevent arbitrary attribute assignments.
- [48:10] __new__ gets called when the object gets created (__init__ gets called when the object has already been constructed).
- [01:01:40] Inheritance is resolved using a C3 Method Resolution Order algorithm.
- [01:04:57] Unicode in Python.
- [01:06:45] UTF8 is not Unicode, it's a Unicode encoding!
- [01:11:50] codecs module automatically converts between encodings.
- [01:13:00] Recommended reading - Functional Programming HOWTO and Python source code ;)
This lecture gets pretty complicated towards the end as the lecturer goes deep into subjects which require adequate experience with Python.
Third Python Lecture: Python: Design and Implementation
Interesting moments in the lecture:
- [01:27] Python started in late 1989, around December 1989.
- [01:57] Python's named after Monty Python's Flying Circus.
- [06:20] Python was first released to USENET and then a public group comp.lang.python was started.
- [08:06] Guido van Rossum, the author of Python, moved to US in 1995.
- [09:58] Python will never become a commercial project thanks to Python Software Foundation, founded in 2001.
- [11:23] Python origins go back to ideas from ABC programming language (indentation for statement grouping, simple control structures, small number of data types).
- [13:01] Being on ABC's implementation team, Guido learned a lot about language design and implementation.
- [16:37] One of the main goals of Python was to make programmer's productivity more important than program's performance.
- [17:10] Original positioning of Python was in the middle between C and sh.
- [21:13] Other languages, such as, Modula-3, Icon and Algol 68 also had an impact on Python's implementation details.
- [24:32] If a feature can be implemented as a clear extension module, it is always preferable to changing the language itself.
- [25:23] The reason Python uses dictionaries for namespaces is that it required minimal changes to the stuff the language already had.
- [28:11] Language features are accepted only if they will be used by a wide variety of users. A recent example of a new language feature is the 'with' statement.
- [31:13] Question from the audience - "Can't the 'with' statement be implemented via closures?"
- [34:25] Readable code is the most important thing.
- [37:57] To add a new language feature, PEP, Python Enhancement Proposal has to be written.
- [40:47] Python's goal was to be cross-platform (hardware & OS) right from the beginning.
- [47:09] Python's lexer has a stack to parse indentation.
- [49:20] Two passes are run over abstract syntax tree, one to generate symbol table and the other to produce bytecode.
- [50:20] Bytecode opcodes are very high level, close to conceptual primitive operations in language, rather close to what hardware could do.
- [01:02:54] Jython generates pure Java bytecode.
- [01:03:01] Jython's strings are always Unicode.
- [01:06:45] IronPython is as fast or even faster than CPython.
Question and answer session:
- [01:08:57] Have there been attempts to compile Python to machine code (for example, x86)?
- [01:13:46] Why not use simple tail recursion?
- [01:16:09] How does the garbage collection work?
This video lecture gives an insight on history and development ideas of Python language. I believe it is important to know the history and details of the language design decisions to be really competent in it.
There are a few more lectures I have found:
- Advanced Topics in Programming Languages Series: Python Design Patterns (Part 1)
- Advanced Topics in Programming Languages Series: Python Design Patterns (part 2)
- Google Developers Day US - Python Design Patterns (a shorter/summary version of previous two)
- Python 3000 (Lecture on the next major Python version)
- ReUsable Web Components with Python and Future Python Web Development
- Introduction to Python for Plone developers (.mov, 184MB) and Download Slides.
There is also some great reading material available:
- a great, free book on Python - Dive into Python,
- a must-read article on Python coding style - Code Like a Pythonista: Idiomatic Python,
- Essential Python reading List,
- Ten quirky things about Python,
- How not to write Python code
Have fun learning Python!
PS. Do you know any other video lectures on Python that I haven't mentioned here? Feel free to post them in the comments! Thanks!