how can I sort a bunch of lists over multiple fields?
Steven Bethard
steven.bethard at gmail.com
Wed Apr 27 16:47:23 EDT 2005
Lonnie Princehouse wrote:
> Might as well make a class for Book instead of dealing with buckets of
> lists...
>
> class Book(object):
> def __init__(self, title, author, publisher, isbn, date): # add
> more fields according to CSV
> self.__dict__.update(locals()) # lazy!
Just for any newbies not paying attention, a slightly less lazy approach
that doesn't leave the Book instance referencing itself would do
something like:
params = locals()
del params['self']
self.__dict__.update(params)
or just write it out:
self.title = title
self.author = author
self.publisher = publisher
self.isbn = isbn
self.date = date
=)
STeVe
More information about the Python-list
mailing list