getting the state of an object

Miki Tebeka miki.tebeka at gmail.com
Sun Oct 7 09:08:53 EDT 2012


> Is there a simple way to get the *ordered* list of instance
Here's one way to do it (weather doing it is a good idea or not is debatable):

    from operator import attrgetter

    def __init__(self, a, b, c, d):
        self.a, self.b, self.c, self.d = a, b, c, d
        get = attrgetter('a', 'b', 'c', 'd')
        self.state = lambda: get(self)



More information about the Python-list mailing list