A Crash, Smash, Kaboom Course in Python

Author: Catherine Devlin
Location:Ohio LinuxFest
Date: Oct. 11, 2008

Slides & code at catherinedevlin.blogspot.com

Warning

Rerun of OLF 2007 talk

No new content

Programming is about

Writing code?

Reading code!

Python is

Python is

READABLE

Python preferred

"Ubuntu prefers the community to contribute work in Python."

www.ubuntu.com/community/developerzone/bounties

"If you are planning to develop an application or courseware for the OLPC, then you should use the OLPC Python Environment to build it."

wiki.laptop.org/go/Getting_involved_in_OLPC

Outline

start at raw prompt

name = 'earth'

Interactive:

dynamic typing

introspection

visual is a module specifically downloaded & installed

function definitions

indentation

arguments

Modules

Small core

Large standard library:
import

Your distro's repository

Modules

Cheese Shop:
easy_install
Elsewhere:
python setup.py install

Aggregate data types

Lists:

[1, 2, 'buckle my shoe']

Tuples:

(3, 4, 'shut the door')

Aggregate data types

Dicts:

roman = {1: 'I', 2: 'II', 'one': 'I'}

roman['one']

dict(earth='harmless')

( go play )

Gotchas

Gotchas

fn() calls fn; fn just points to it:

>>> "shout".upper()
'SHOUT'
>>> "mumble".upper
<built-in method upper of str object at 0xb7d13040>

Functions are objects

>>> s = 'shout'
>>> funcs = s.upper, s.title, s.isalpha
>>> funcs
(<built-in method upper of str object at 0xb7d43d00>, <built-in method title of str object at 0xb7d43d00>, <built-in method isalpha of str object at 0xb7d43d00>)
>>> for func in funcs:
...     func()

'SHOUT'
'Shout'
True

Stop! Don't write that!

It's already been written!

  • Python Standard Library
  • Cheese Shop
  • Know the community

Learning

Tutorial www.python.org

Topic Guides

More resources

Python Cookbook

iPython: enhanced interactive prompt

On other platforms

No differences

Module availability

subset of Standard Library

subset of 3rd-party modules

all FCL, Java libraries, etc.

IronPython

Jim Hugunin IronPython video

Graphics packages

Web app platforms

Editors & IDE's

Community

ClePy

MichiPUG

centralOH@python.org

Blogs: Daily Python-URL

Community

PyOhio 2009

Columbus

Summer 2009

pyohio.org

Community

PyCon 2009

Chicago

March 27 - 29

us.pycon.org

That's just 369 miles from here!

Community

Join centralOH@python.org

Python-powered

S5
ReStructured Text

Bruce

visual

catherine.devlin@gmail.com

IntelliTech Systems

catherinedevlin.blogspot.com

Bunnies