What are we covering?
- Enough Python for tomorrow's Django class
- (but Django ≠ Python; Django, the web framework, is written in Python)
- But we're assuming some programming experience
- If you're a non-programmer, this may be a bit fast paced.
- But if you're an experienced Pythonista, you may find that you're already familiar with most of the stuff we're covering.
- Introduction and Setting Up
- (Possibly) Modules, virtualenv, pip/easy_install
BTW! OOP, Unit Testing, maybe decorators, and maybe magic methods will be up after this presentation.
- A little about Python, about this presentation (meta!) and actually getting set up
- Syntax AND some basic control structures
- Functions... defining your own, built in, and scoping
- Organizing your code, using and creating modules and packages
- joeversoza at gmail
- Worked with Python on and off for about 2.5 years
- Taught beginners programming, in as3, processing, etc
- Don't do as much programming anymore so teaching is a great way to stay involved
- Run-of-the-mill slideshows
- Live demos with the Python interactive shell (yikes!)
- Some actual coding
- I promise some pics to break up the monotony
- Live demos - asking for trouble!
- Might be hokey
For the rest of this part of this section:
- Python history and language features
- Setting up
Some Python history
- Yes, it was named after Monty Python
- Based on ABC
- Invented in 1991 by this bearded Dutch guy (Guido van Rossum):
- ABC - teaching / prototyping language meant to replace BASIC, Pascal, etc
- Also known as Python's "Benevolent Dictator for Life"
Where it's going (and how it's getting there)
- Two active branches of Python: 2.x and 3.x
- Python Enhancement Proposals (PEPs)
- CPython - reference implementation, but there are others
- The Python Software Foundation (PSF)
- 3.x meant to remove duplicate features and perceived flaws with prior implementation
- 3.x is not backward compatible, but some features have been backported
- PEPs provide structure for evolution and dev of Python; add language features as well as conventions
- (C, Java, C#), and new implementations are maturing (PyPy - Python in Python!)
- PSF - non-profit organization that provides organizational structure, governance and community building
Where you've seen it before
- Frameworks like Django (Disqus), Turbogears (SourceForge), Pylons (reddit)
- First language supported by Google AppEngine
- Original Bittorent client
About the language
- Dynamic / interpreted programming language
- Dynamically typed
- Strongly typed
- Whitespace significant
- Comprehensive standard library
- Technically it's compiled to bytecode, much like Java or c#, but there's no explicit compilation step
- Dynamically typed - type checks are done at run time rather than compile time, allowing for for types and functionality to be generated at run time... allows duck typing (ex file-like classes in python)
- Imperetive, object oriented, and to some extent, functional programming
And all of that means...
- Ease of use
- Easier to Ask Forgiveness than Permission (EAFP)
- One obvious way to do things
- Batteries included
- Ease of use - no need to wait for compile, no need to declare types, type checking at runtime
- EAFP - duck typing and exceptions
- Readability - forces proper indentation; whitespace is both human and computer "readable"
- Batteries Included - large standard library
The current 2.x release is 2.7.2, so we'll target that for our exercises.
- Python installed by default on OSX or Ubuntu
- Windows XP and later: http://www.python.org/download/releases/
- SSH to the server provided by the conference
- Or try the browser: http://www.jitouch.com/pycloud/
- Although Python 3.x is the eventual future of Python, it hasn't been widely adopted in production systems yet, so we're going with 2.x
- 2.7.1 is on Lion and Natty
- Though for most of what we're doing, 2.7.x or 2.6.x should suffice
- For Windows, I've heard that there may be some PYTHON_PATH issues
- For the server (putty on windows, or ssh on OSX, Linux), you may be constrained a bit (no installing packages?)
- The browser based interpreter is really a Python to JS compiler. Definitely can't install packages.
Test your install by typing "python" in terminal or cmd.exe
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print "Hi PyGotham!"
Some miscellaneous links
Some miscellaneous (mostly non-Python) links
- http://paulrouget.com/dzslides/ for the slideshow
- http://pages.github.com/ for hosting
- https://github.com/mojombo/jekyll for publishing tools