Comments on my "Python Introduction" slides
Bryan
belred1 at yahoo.com
Mon Aug 25 23:38:30 EDT 2003
i always seem to prefer using
if key in dictionary:
rather than
if dictionary.has_key(key):
i also seem to prefer using
for line in file(fname):
rather than
for line in open(fname).readlines()
not sure it's any better, faster, more readable... just my preference. so your frame 7 would be:
def unique(fname):
'''Prints unique lines in fname'''
h = {}
for line in file(fname):
line = line.strip()
if line not in h:
h[line] = True
print line
---
frame 8: you should also list empty tuple, list and dict as having a False value too)
frame 9: needs a note that it's for 2.3+
frame 10: IMO "Magic methods" has a negative connotation. but maybe it's the correct terminology
frame 12: i know python has a c interface for c extension modules, but can't modules also be written is c++ (ie. boost?)
frame 18-19: i would show the exact same example in each. it appears from your slide that wxPython is way more complicated than TK
i enjoyed going though it... nice work...
bryan
More information about the Python-list
mailing list