0% found this document useful (0 votes)
110 views74 pages

Practical Python Programming: Charlene - Nielsen@Ualberta - Ca May 23Rd and 24Th, 2013 9:00 A.M. To 12:00 Noon Biosci B118

Uploaded by

dereje
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views74 pages

Practical Python Programming: Charlene - Nielsen@Ualberta - Ca May 23Rd and 24Th, 2013 9:00 A.M. To 12:00 Noon Biosci B118

Uploaded by

dereje
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

Practical Python Programming

[email protected]
May 23rd and 24th, 2013
9:00 a.m. to 12:00 noon
BioSci B118
Practical Python Programming
B118 Computer Access
1. Boot the machine in the Windows operating system
2. To access the internet: AUTHENTICATE
using your CCID and password
3. Right-click on the START button to ‘Explore All Users’
4. Navigate to the WORKSPACE directory on the C drive
5. In a web browser, download the following to
C:\WORKSPACE from: bit.ly/ppp-zip
6. Extract all/Unzip ppp.zip in to C:\Workspace\ppp
7. Open the pdf files and resize the PDF reader window
to fit part of the monitor screen
Outline

• Who, when, what, where, why, how?


• Easy environments
• Programming primer
• Coding conventions
• Fussing with the flow
• Script samples
• Excellent e-resources
Who am I?
Charlene Nielsen
[email protected]

GIS Analyst in Biological Sciences


www.biology.ualberta.ca/gis
Who is this workshop for?
• You, if you:
– Know how to use a computer and the web
– Have never programmed before but have a
strong desire to learn how
– Are willing to type a lot to make the
information stick (no copy paste allowed)
– Are an experienced programmer and want to
play with a new language
Who uses it?
• Web Development

• Graphics

• Financial

• Science

http://wiki.python.org/moin/OrganizationsUsingPython
Who uses it?
• Electronic Design Automation

• Software Development

• Education

• Business Software

• Government
http://wiki.python.org/moin/OrganizationsUsingPython
Who is responsible for Python?
• Created by Guido van Rossum
– born 31 Jan 1956 (Netherlands)
– currently works at Google (since 2005)

• Actively maintained by worldwide users (including van Rossum)


When?
• 1989 "hobby" programming project
– interpreter for a new scripting language descendant of
ABC that would appeal to Unix/C hackers
– needed a name that was short, unique, and slightly
mysterious – so was named Python as a working title
• 1991 code first published (version 0.9.0)
• 2001 the Python Software Foundation was formed

More history:
http://docs.python.org/release/2.6.5/license.html
http://en.wikipedia.org/wiki/History_of_Python
When to (not) use it?
• PRO: Suitable for everyday tasks,
therefore minimizing the amount of time a
programmer spends on a project

• CON: Often less efficient than languages


such as Java, C, and C++, therefore, not
good when creating a new operating
system
What is it?
• A remarkably powerful, dynamic, object-oriented,
interpreted, high-level programming language
that is used in a wide variety of application domains
• Named after the comedy troupe: Monty Python
What release: 2 or 3? I’m the
tried
and true
• “Python 2.x is the status quo,
blue #2!
Python 3.x is the shiny new thing.”
• 2.7 is the last major release for 2.x,
with statement of extended support
• 3.1 is the intended future of the “cleaned up” language,
with less regard for backwards compatibility
• A lot of third party software doesn't work on 3.x yet…
I’m the
• “Well written 2.x code will actually be a lot like 3.x code” clean
and
• Handy tools for compatibility:
shiny #3!
– http://wiki.python.org/moin/2to3
– http://wiki.python.org/moin/3to2

http://wiki.python.org/moin/Python2orPython3
What can it do?
And
Run Web sites more! Build test suites for
C or Java code

Write GUI
interfaces
Process large
XML data sets
Control number-
crunching code on
supercomputers Make a commercial
application scriptable
by embedding the
Python interpreter
inside it

Image from “Head First Python” book by Paul Berry

http://www.headfirstlabs.com/books/hfpython/
Where can it be found?
• www.python.org Follow the easy online
installation instructions!

• https://www.enthought.com/products/canopy/
academic/

• Automatically with certain operating systems


(e.g. Mac and Linux)

• Installed alongside software applications that


incorporate its scripting functionality
(e.g. Esri ArcGIS)
Where can it be used?
• All major operating systems
– Windows

– Linux/Unix

– OS/2

– Mac

– Amiga

And operating systems on mobile devices!


Why use it?
• Simplicity
and ease of
understanding
– Programs look neat
and clean
– Has few unnecessary
symbols
– Straightforward
English names instead
of the cryptic syntax
common in other
languages

Note: ‘import antigravity’ only works in version 3.x, print statement is from 2.x
http://xkcd.com/353/
Why use it?
• Programmability
– Wide range of readymade libraries that can be (freely!) used in
your own programs; i.e. “batteries included”
– Supports, but doesn't force, object-oriented programming (OOP)
– Integration with other languages (e.g. Java, C)

“Python Foot” graphic by David Day


Why use it?
• Free
– Doesn’t cost – freely usable and
distributable – even for commercial use
– Open source code
– Sizable community of developers with
online support groups

www.pycon.org

www.scipy.org
How can it be used?
• Scripting
– ‘gluing’ together commands for other software applications

• Programming
– text processing, web site development, email, scientific computing
www.devsource.com/c/a/Languages/More-Than-Five-Things-You-Didnt-Know-You-Could-Do-With-Python/
• Python does COM
• Python does .NET
• Python does Java better than Java
• Python is high-performance
• Python talks to hardware

• Education
– MIT and other institutions use Python as the programming
language in their introductory computer science courses
How can it be learned?
• Official Python tutorial
http://docs.python.org/release/2.6.5/tutorial/index.html

• Online resources, including “free” e-books


through UofA’s Libraries (listed at the end)

• Hands-on now!
Easy environments
• Command line
– The interpreter

• IDE (IDLE):
Integrated
DeveLopment
Environment
– Interactive window
– Script window

• Other software
(not used in this workshop)
The Python Interpreter
We’re going to skip the command line, and go on to…
IDLE for Python in B118
Click the START button
> PROGRAMS
> ARCGIS
> PYTHON 2.6
> IDLE (PYTHON GUI)

We are using the ArcGIS default installation of the Integrated DeveLopment Environment because it is
readily available for GIS development. Many other IDEs (discussed later) are available for your use,
but this one makes interacting with ArcGIS easy breezy.
IDLE: Interactive window

http://docs.python.org/library/idle.html
http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html
Interactive window menu: File
Open an existing module
Create a new editing window (searches sys.path)
Open an existing file Show classes and methods
Open a list of recent files in current file
Show sys.path directories,
modules, classes and
Save current window to the methods
associated file (unsaved
windows have a * before
Save current window to new
and after the window title)
file, which becomes the
associated file
Save current window to
different file without Print the current window
changing the associated file
Close current window (asks
to save if unsaved)
Close all windows, quit
(asks to save if unsaved)
Interactive window menu: Edit 1
Undo last change to current
window (A maximum of
1000 changes may be
undone) Redo last undone change to
current window

Copy a selection into Copy selection into system


system wide clipboard, then wide clipboard
delete the selection
Select the entire contents of
the edit buffer
Insert system wide
clipboard into window
Open a search dialog box
with many options

Ask for a line number and Open a search and replace


show that line dialog box
Interactive window menu: Edit 2

Search for the string in the Repeat last search


selection

Open a search dialog box


for searching files Open a scroll window
allowing selection keywords
Open a small window with and attributes
function param hints
Expand the word you have
typed to match another
Highlight the surrounding word in the same buffer;
parenthesis repeat to get a different
expansion
Interactive window menu: Other
Scroll the shell window to the last restart
Restart the interpreter with a fresh environment

Look around the insert point for a


filename and linenumber, open Run commands in the shell
the file, and show the line under the debugger
Show the stack traceback of the Open stack viewer on
last exception traceback

Toggles the window between configured size and


maximum height.
The rest of this menu lists the names of all open
windows; select one to bring it to the foreground
(deiconifying it if necessary).

Shell and Debug menus are not available in the script window
Interactive window menu: G.T.K.*
Open a configuration dialog. Fonts, indentation,
keybindings, and color themes may be altered. Startup
Preferences may be set, and Additional Help Sources
can be specified. On MacOS X this menu is not
present, use menu 'IDLE > Preferences...' instead.

Version, copyright, license, credits


Display summary file on
Access local Python documentation, if installed. all menu items
Otherwise, access www.python.org.
(Additional Help
Sources may be added
here using Options >
Configure IDLE…)

*G.T.K. = Good To Know!


Now try this…
• Click Help > IDLE Help
– Close when finished
reading

• Click Options > Configure


IDLE
– Examine each tab and
modify as needed
– E.g. change font
(Fonts/Tabs tab)
– E.g. add custom web/file
help link/path (General tab
and click Add button)
Programming primer
• Program
– A set of instructions or recipe that tells the
computer what you want it to do
Programming primer
• A Python program is divided into lines
– Each line physically ends before a newline
– Lines that are blank (contain only spaces, tabs, formfeeds and
possibly a comment) are ignored
– Breaking up statements on separate lines will break
your program!
thesunshines = True

itsraining =
False
Programming primer
• Indentation and whitespace required
– Leading whitespace (i.e. spaces) at the beginning of a
logical line is used to compute the indentation level of the line,
which in turn is used to determine the grouping of statements
– Trailing whitespace is ignored
– All lines you want grouped together must be indented
identically!
thesunshines = True
while thesunshines:
{(No
print “Skip work and go to the beach”
BEGIN/END
or braces)} thesunshines = False
Programming primer
• Comments
– Helps explain what the code is doing
– Ignored when executed
– Two ways to indicate comments:
# type comment here
“““ type comment here ”””

• Command prompts (interactive mode only)


>>>
...
Now try this…
• Type the following in the interactive window:
>>> import this
>>> help()
>>> import Do NOT type the >>>
>>> topics
>>> NUMBERS
>>> strings # note the lower case

• Type quit or press Ctrl-C to exit the help system


Now try this…
• Type the following in the interactive window:

>>> help(keywords) # now retype with quotes around ‘keywords’

>>> help(‘print’)

>>> print ‘what is a blue moon?’

>>> abluemoon = ‘second to last full moon in a four-moon season’

>>> print abluemoon

>>> for once in abluemoon:


print once # this is looping, we’ll learn about it later

• Type Alt-P a couple of times (and try Alt-N)


Building blocks
• computer
Computer programs  modules  statements  expressions
modules statements expressions
programs

• Difference between a statement and an expression:


– Statement does something
(or, rather, tells the computer to do something; e.g. print or assignment)
– Expression is something

• Expressions consist of:


– Literal values
– Variables
– Operators
– Parentheses (to override the built-in precedence system)
– And some other things…

http://docs.python.org/reference/lexical_analysis.html
Literals
• Notations for constant values of some
built-in types (i.e. the stuff you type directly)
– Numeric = plain integers, long integers,
floating point numbers, and imaginary numbers
– Strings = text
enclosed in ‘single quotes’ or “double quotes”

help(‘STRINGS')
help(‘NUMBERS’)
Variables
• A name that represents or refers to a value
(i.e. the stuff you want stored for various uses)
– Dynamic – no need to define the type up front
– Created through an assignment statement that gives them
values using the ‘=’ operator
– If you don’t have an assignment (i.e. a name to the left of the ‘=’)
then Python stores it in the default result variable ‘_’
(note: type ‘_’ at the command prompt to view current value)

“Programmers use these variable names to make their code read more
like English, and because they have lousy memories. If they didn’t use
good names for things in their software, they’d get lost when they tried
to read their code again.”
(“Learn Python the Hard Way” by Zed Shaw)
Operators
• Tokens that work with or operate on values
• Includes:
– Arithmetic
– Assignment
– Comparison
– Bitwise
– Logical
– Membership
– Identity
(Note: The smaller-font ones are not included in the next set of slides; look them up in the help!)

help('OPERATORS')
http://www.tutorialspoint.com/python/python_basic_operators.htm
Operators: Arithmetic
+ Add (Note: Concatenation when used with strings)

- Subtract

* Multiply (Note: Repetition when used with strings)

** Exponential (power) calculation

/ Divide

% Modulus – return remainder from division

// Floor Division – return quotient from division


Operators: Comparison
== Equal to*

!= Not equal to (also <>)

> Greater than

< Less than

>= Greater than or equal to

<= Less than or equal to

*Remember that a single ‘=‘ sign is the assignment operator!


Operators: Assignment
Simple assignment operator*
= (assigns values from right side operands to left side operand)
Add AND assignment operator
+= (add right operand to the left operand and assign the result to left operand)
Subtract AND assignment operator
-= (subtract right operand from the left operand and assign the result to left operand)
Multiply AND assignment operator
*= (multiply right operand with the left operand and assign the result to left operand)
Divide AND assignment operator
/= (divide left operand with the right operand and assign the result to left operand)

*Remember that a double ‘==‘ sign is the equality operator!


Keywords
• A reserved word or identifier that has a particular
meaning to the programming language
• They must be spelled exactly as typed here:
and elif if print
as else import raise
assert except in return
break exec is try
class finally lambda while
continue for not with
def from or yield
del global pass
help(‘keywords')
http://docs.python.org/reference/lexical_analysis.html#keywords
Now try this…
• Type the following in the interactive window:
>>> 1 + 2 + 3
>>> _
>>> _ - 4
>>> a = 1
Case is important!
A is NOT the same as a
>>> b, c = 2, 3
>>> A + b * c # then type a + b * c
>>> ‘stuff’
>>> _

Do NOT type the >>>


Now try this…
• Type the following in the interactive window:

>>> # calculator expressions

>>> # commenting and docstrings Samples


>>> # print statements demonstrated here
are provided in
>>> # sequences
the PDF document

• IDLE is well-suited for testing out bits of code to


see how it works!
IDLE: Script window
• From the menu of the interactive (Python Shell) window,
click File > New Window
– A new blank window (a.k.a. file editor) is used to type our
programs in
Script window menu

Open a pane at the top of the edit window which shows


the block context of the section of code which is
scrolling off the top or the window

Open or wake up the Python shell window

Run a syntax check on the module

Execute the current file in the __main__ namespace

Shell and Debug menus are not available in the script window
But, all the previously shown ones are: File, Edit, Windows, Help!
Run menu is not available in the interactive window
Script window menu: Format
Shift selected lines right 4 spaces

Shift selected lines left 4 spaces

Insert ## in front of selected lines

Remove leading # or ## from selected lines

Turn *all* tabs into the right number of spaces

Open dialog to change indent width

Reformat the current blank-line-separated paragraph

Format menu is not available in the interactive window


A script
• A text file containing the statements that
comprise a Python program
• Reusable, reusable, reusable – once created,
the script can be executed over and over without
having to retype it each time
• Any file editor (that saves as plain ASCII) can be used,
but name the file with a .py extension
• But don’t forget about interactive mode completely, it
makes an excellent testing ground
Coding conventions
• Style Guide for Python Code
http://www.python.org/dev/peps/pep-0008/
– 4 spaces per indentation (no tabs ever)
– Maximum line length of 79 characters
– Always import modules:
• after initial comments or docstrings
• import them separately
• don’t scatter them throughout your code
– Name:
• modules with lowercase
• classes with CapWords
• functions with lower_case_with_underscores
• constants with UPPERCASE (and possibly “_”)
– Use blank lines to separate groups of related code
– Surround operators with single space on either side
– Avoid extraneous whitespace in other situations
– Consistency! You really should read through PEP 8
Now try this…
• Type some of the previous statements you`ve already
tried in to the script window
Samples
demonstrated here
are provided in
the PDF document
• Save with a meaningful name and a .py extension to
your working directory
• Optionally, click Run >>> Check Module
• Click Run >>> Run Module (or the F5 key)
Fussing with the flow
• Control the behaviour of a script by testing conditions
and looping through values
• Flow control statements (similar to other programming languages)
specify how the program is executed
– if
– while
:
– for
– Also try and with (but not covered in this workshop)

• Keyword statement (typically) followed by a colon and


an indented block

http://docs.python.org/release/2.6.5/reference/compound_stmts.html
if
• The if statement is used for conditional execution, a.k.a.
testing values and making decisions

• Details: lets you perform an action (another statement or more) if


a given condition is true; if the condition is false, then the
block is not executed

• Remember: when testing equality use == (and not =)

• Extending the testing:


– elif allows you to check multiple expressions for truth value and
execute a block of code as soon as the first one of the conditions
evaluates to true (all following elif expressions are ignored)
– else is a catch-all in case previous condition(s) not met

http://docs.python.org/release/2.6.5/reference/compound_stmts.html
if
• Generic syntax:
if expression: Most basic
statement(s) minimum coding
elif expression:
statement(s)
else:
statement(s)

• Can be abbreviated as a conditional statement:


x = true_value if condition else false_value

http://docs.python.org/release/2.6.5/reference/compound_stmts.html
while
• The while statement is used for repeated execution as
long as an expression is true

• Details: keeps executing (another statement or more) until the


condition becomes false

• Remember: to code a finite loop; i.e. prevent the possibility


that this condition never resolves to a false value (unless an
infinite loop is actually desired)

• Generic syntax:
while expression:
statement(s)

http://docs.python.org/release/2.6.5/reference/compound_stmts.html
for
• The for statement is used to iterate over the elements of a
sequence (such as a string, tuple or list) or other iterable object

• Details: causes a section of a program to be repeated a


certain number of times by iterating (i.e. counting each)

• Remember: this can loop through list-like objects and/or


numeric ranges

• Generic syntax:
for iterating_var in sequence:
statements(s)

http://docs.python.org/release/2.6.5/reference/compound_stmts.html
Now try this…
• Type the following in the script window:

>>> # if

>>> # X if C else Y Samples


demonstrated here
>>> # while
are provided in
>>> # for the PDF document
Built-in functions
• A series of statements
which returns some value
to a caller
(it can also be passed zero or more
arguments for its use/execution)
• Objects that can be used
by all Python code without
the need of an import
statement
dir(__builtins__)
http://docs.python.org/release/2.6.5/library/functions.html
Built-in functions
Some of the tools that are always available to use:

abs(x) globals()
bin(x) help([object])
cmp(x, y) hex(x)
complex([real[, imag]]) id(object)
dict([arg]) input([prompt])
dir([object]) int([x[, base]])
divmod(a, b) isinstance(object, classinfo)
enumerate(sequence[, start=0]) iter(o[, sentinel])
eval(expression[, globals[, locals]]) len(s)
file(filename[, mode[, bufsize]]) list([iterable])
float([x]) locals()
format(value[, format_spec]) long([x[, base]])

See http://docs.python.org/release/2.6.5/library/functions.html for complete listing


Built-in functions
More selected tools:

map(function, iterable, ...) set([iterable])


max(iterable[, args...][, key]) sorted(iterable[, cmp[, key[, reverse]]])
min(iterable[, args...][, key]) str([object])
oct(x) sum(iterable[, start])
open(filename[, mode[, bufsize]]) tuple([iterable])
pow(x, y[, z]) type(object)
range([start], stop[, step]) type(name, bases, dict)
raw_input([prompt]) vars([object])
reversed(seq) xrange([start], stop[, step])
round(x[, n]) zip([iterable, ...])

See http://docs.python.org/release/2.6.5/library/functions.html for complete listing


User-defined functions
• A block of organized, reusable code that is used
to perform a single related action, that you create

• Similar to procedures, subroutines, and functions


in other programming languages, but may or may
not return a value

• Generic syntax:
def functionname( parameters ):
Required """function_docstring"""
keyword: def function_suite
defines the return [expression]
function
Modules
• Basically, subprograms that define things,
e.g. functions, classes, variables
• Built-in (as opposed to user-defined) modules
are also called standard libraries

http://docs.python.org/release/2.6.5/library
http://www.doughellmann.com/PyMOTW/
Modules
• Different ways to grab these extra tools:
1. import <module name>
• Requires module name as prefix to tools
e.g. import random
randvalue = random.random() * 100

2. from <module name> import <function>


• Reduces typing for commonly used tools
e.g. from random import random
randvalue = random() * 100

3. from <module name> import *


(this way is not advised because it causes clutter)
The Cheese Shop
• The Python Package Index is
one-stop ‘shopping’ for all registered
module packages:
http://pypi.python.org/pypi
Now then,
• Searchable! some cheese
please, my
good man.

Certainly, sir.
What would
you like?
Error handling
• As with all things and in Python, it’s
Easier to Ask Forgiveness
than Permission
i.e. try and perform an operation; if all goes well, great;
if not, ask for forgiveness…

• This is typically done with


try/except
• The FAQ is a worthwhile read:
http://docs.python.org/faq/index.html
Script samples
• Start a new file for each of the scripts
below. Make notes (comments in the code
will do!) if you think the instructor says
something important during this hands-on
demonstrations of practical Python
programming. Especially note the built-in
modules highlighted from the standard
library.
Skeleton script suggestion
• Set up a generic_code.py (name it what you want)
• Use comments/docstring at the top to indicate the
filename, date(s), your name, optional contact info, and
details about what the script requires and does
• Type out the basic structure of your common coding
needs; including import <commonly used module(s)>
• Open the file when you’re ready to start a new program,
simply saving as a new appropriate name before
modifying
Five tips for Python
1. Don't work too hard – let Python do the work for you by using
the stuff built in to its standard library

2. Don't write a loop when a comprehension will do –


built-in syntax for transforming one data structure (lists,
dictionaries) into another version of itself without resorting to
iteration

3. Learn as you go, not all at once, and learn constantly


(remember, concepts are the important things)

4. IDLE is often good for quick jobs (and has some useful
tools)

5. Don't reinvent the wheel – check the Python Package Index


(PyPI) first

From author of “Head First Python” book - Paul Berry


http://answers.oreilly.com/topic/2227-how-to-tackle-python-head-first/
Future Python group activities
• Python Scripting for ArcGIS…

• Software Carpentry:
http://software-carpentry.org

• MIT Intro to Computer Science Programming:


http://academicearth.org/courses/introduction-to-
computer-science-and-programming

• Read the related article on the importance of programming skills:


http://www.python.org/doc/essays/cp4e.html

http://www.python.org/community/sigs/current/edu-sig/
E-resources
(online links to software, documentation, free books, tutorials, sample code, and articles)

• http://www.python.org/
• http://hetland.org/writing/instant-python.html
• http://rgruet.free.fr/PQR26/PQR2.6.html
• http://diveintopython.org/
• http://www.headfirstlabs.com/books/hfpython/
• http://learnpythonthehardway.org/
• http://greenteapress.com/thinkpython/
• http://homepage.mac.com/s_lott/books/python.html
• http://www.tutorialspoint.com/python/
• http://www.developer.com/lang/other/article.php/3624681/Python-Tutorial-Index-Page.htm
• http://www.swaroopch.com/notes/Python
• http://www.korokithakis.net/tutorials/python
• http://oreilly.com/python/
• http://en.wikipedia.org/wiki/Comparison_of_programming_languages
• http://code.activestate.com/recipes/langs/python/
• http://pypi.python.org/pypi
• http://www.python.org/doc/humor/
UofA e-books
(subscription is accessible through an on-campus computer with a UofA IP address or CCID login)

http://www.springerlink.com/
• Pro Python, Marty Alchin
• Python Programming Fundamentals, Kent D. Lee
• A Primer on Scientific Programming with Python, Hans Petter Langtangen
• Python Scripting for Computational Science, Hans Petter Langtangen
• Beginning Python Visualization: Crafting Visual Transformation Scripts, Shai Vaingast
• Dive Into Python, Mark Pilgrim
• Foundations of Agile Python Development, Jeff Younker
• Beginning Python: From Novice to Professional, Magnus Lie Hetland

http://site.ebrary.com/lib/ualberta/home.action
• Python Programming for the Absolute Beginner, Michael Dawson
• Gray Hat Python: Python Programming for Hackers and Reverse Engineers, Justin Seitz
• Python: Create - Modify – Reuse, James O. Knowlton
• Python Power!: The Comprehensive Guide, Matt Telles

Most recently published (and latest editions) listed from top to bottom
UofA e-books
(subscription is accessible through an on-campus computer with a UofA IP address or CCID login)

http://proquest.safaribooksonline.com/
• The Python Standard Library by Example, Doug Hellman
• Programming Python, Mark Lutz
• Python Algorithms: Mastering Basic Algorithms in the Python Language, Magnus Lie Hetland
• Head First Python, Paul Barry
• Python Testing, Daniel Arbuckle
• The Quick Python Book, Vern Ceder
• Python Programming for the Absolute Beginner, Michael Dawson
• Python Pocket Reference, Mark Lutz
• Learning Python, Mark Lutz
• Python Essential Reference, David M. Beazley
• Python: Visual QuickStart Guide, Toby Donaldson
• Expert Python Programming: Learn best practices to designing, coding, and distributing your
Python software, Tarek Ziadé
• Python Programming in Context, Bradley Miller and David Ranum
• Python Power!: The Comprehensive Guide, Matt Telles
• Python Phrasebook: Essential Code and Commands, Brad Dayley
• Core Python Programming, Wesley J. Chun
• Python in a Nutshell, Alex Martelli
• Python Cookbook, Alex Martelli, Anna Ravenscroft, and David Ascher
Do you feel like
So, are you now a you’ve found the
fledgling OR ‘holy grail’ of
pythoneer? programming
languages?

You might also like