[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版

(yzsuai) #1
>>> db['guido'].job
'BDFL'
>>> list(db['guido'].name)
['G', 'v', 'R']
>>> list(db.keys())
['sue', 'bill', 'nobody', 'tomtom', 'tom', 'bob', 'peg', 'guido']

Here in action again is the original database script we wrote in Example 1-19 before
we moved on to GUIs and the web; there are many ways to view Python data:


...\PP4E\Preview> dump_db_classes.py
sue =>
Sue Smith 60000
bill =>
bill 9999
nobody =>
John Doh None
tomtom =>
Tom Tom 40000
tom =>
Tom Doe 90000
bob =>
Bob Smith 30000
peg =>
1 4
guido =>
GvR <shrubbery>
Smith
Doe

Future directions


Naturally, there are plenty of improvements we could make here, too:



  • The HTML code of the initial input page in Example 1-33, for instance, is some-
    what redundant with the script in Example 1-34, and it could be automatically
    generated by another script that shares common information.


Figure 1-19. Same object displayed in the GUI


68 | Chapter 1: A Sneak Preview

Free download pdf