nov 16
The
questions page has been updated with info on docstrings, for loops, and assertions.
your work
Discuss homework
- my version of the poker doctest assignment.
- look over some of your code?
- questions about anything?
Discuss your final project ideas - and see more ideas below
various python uses
image processing :
http://www.gimp.org/docs/python/ within GUI app
http://wiki.python.org/moin/ImageMagick command line
3D modeling and animation :
http://www.blender.org/development/ (e.g. 2.49 Python API Reference)
numerical scientific work :
numpy.scipy.org
games : http://wiki.python.org/moin/PythonGameLibraries
audio : http://wiki.python.org/moin/Audio
robots :
1. pyrorobotics.org : a python robot API, including simulators
2. www.roboteducation.org : another python robot API
python systm is "myro"
typical robot is "scribbler", about $200
http://www.georgiarobotics.com/roboteducation
but apparently no simulator
internet :
network events : twistedmatrix.com
web frameworks : django pylons, google app engine, etc
(but you also need HTML, CSS, JavaScript, etc)
data structures
We've talked about lists (and the similar tuples) and dictionaries.
These really become powerful when you start embedding them :
- build up tree-like data structures.
- check out the pprint module (give an example)
- often mixed types of content
- often embedded within class or classes
Look at some examples :
- list of lists :
- matrix
- board for game
- list of students, list of grades for each student
- list of dicts
- list of students, name/phone/address by key for each
- dict of lists
- hand of cards; keys by suits, each a list of cards
- dict of dicts
- keys north,south,east,west; dict scene description for each
Specific example: the ATM machine
objects might be something like
GUI - all interaction with user
Data - file input/output
Person - name, password
Account - each pot of money, e.g. checking, savings
Transaction - deposit or withdrawal or transfer with time
The Data object could put the information could be stored
in a single python data structure,
stored as a string in a file with pprint
read in as a string and then eval() to put it into a variable,
which could then be converted to, say, a list of Persons,
each with a list of history Transactions and several Accounts.
The storage file might look like this :
[{'name': 'John Smith', 'password':'...',
'accounts': [
{'name':'checking', 'balance': 120.23 # or store as pennies},
{'name':'savings', 'balance':4000.00
],
'transactions': [
{'date':..., 'amount':..., 'from':..., 'to':...},
{...},
]
},
{ # similar for another person }
]
The the top level of the program might be something like
storage = Data('stored_data.txt')
people = storage.readPeople()
gui = GUI(people)
while True:
person = gui.login() # ask for name/pass; return user if match
while person.transaction():
storage.save() # update disk file
where several of these objects contain the others, and would call methods on some of the others to get the work done.
I'm imagining that Data contains a list of people, and so can use that to get a string to send to the file.
Likewise, each person contains the gui, so person.transaction() would
- use gui to ask about what to do,
- create a Transaction object and append it
- update the person's balances, and
- return False if user is done.
what's next
For this Thu and next Tue, before spring break,
look at the last chapter in the text: algorithms and recursion.
After break, minimal assignments while you work on projects.
In class, I'll go over some of the python uses mentioned above: robots, the internet, science, etc.
Are we having fun yet?