list of lists
Max M
maxm at mxm.dk
Wed Sep 17 02:18:05 EDT 2003
More information about the Python-list mailing list
Wed Sep 17 02:18:05 EDT 2003
- Previous message (by thread): list of lists
- Next message (by thread): getch() in Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Peter Otten wrote: > Nice explanation. I take the occasion to warn newbies that the sort() method > is a showstopper in this scheme: > > getArray().sort()[3].formatter() #BAD CODE, DON'T USE > ^ > | > + -- sort() returns None > > By the way, is there any Python programmer who has not made this error at > least once? Also it is a slower approach if you want to look up more than one item in the list. In that case it is better to bind the sorted result of getArray to a variable. arr = getArray() arr.sort() arr[3].formatter() arr[4].formatter() arr[5].formatter() So I find that I rarely use the short form of the expression. regards Max M
- Previous message (by thread): list of lists
- Next message (by thread): getch() in Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list