Although Perl to Python Migration, by Martin C. Brown, Addison Wesley (2002) is out of print, I think this is a very good and practical book to learn Python, especially for those who are thinking of moving from Perl to Python. Here are the errata that I noticed while going through the book.
print 'This is a' + 'concatenated', string ==> print 'This is a' + ' concatenated', 'string'Note a blank before "concatenated", and the quotes around "string".
os.execv('/bin/ls', ('-la')) (2 places) os.execve('/usr/local/bin/cvs', ('commit'), {'CVSROOT':'/export/cvs'}) os.execvp('/bin/ls', ('-la')) os.execvpe('/cvs', ('commit'), {'CVSROOT':'/export/cvs'}) ==> os.execv('/bin/ls', ('-la',)) os.execve('/usr/local/bin/cvs', ('commit',), {'CVSROOT':'/export/cvs'}) os.ececvp('/bin/ls', (-la',)) os.execvpe('/cvs', ('commit',), {'CVSROOT':'/export/cvs'})
The second argument must be a tuple, and single element tuple needs a comma at the end (p.57).
while(1): .... else: break ==> while(1): .... else: break
string.translate(text, maketrans('abcdefg.... ==> string.translate(text, string.maketrans('abcdefg....
date = re.sub(r'(\d{4})(\d{2})(\d{2})', '\3.\2.\1', date) ==> date = re.sub(r'(\d{4})(\d{2})(\d{2})', r'\3.\2.\1', date)
lines = myfile.lines() ==> lines - myfile.readlines()
Updated 2006-02-05, Taku Yamanaka [taku[AT]hep.sci.osaka-u.ac.jp