Using an interable in place of *args?
David M. Wilson
dw-google.com at botanicus.net
Fri Nov 21 20:09:22 EST 2003
Nick Vargish <nav+posts at bandersnatch.org.invalid> wrote...
> def __init__(self, structure, hasblob = False):
> self.format = ''.join([ y for x, y in structure ])
> self.fields = [ x for x, y in structure ]
> self.hasblob = hasblob
> for v in self.fields:
> self.__dict__[v] = None
Just random passing code commentary:
def __init__(self, structure, hasblob = False):
self.format = ''
self.fields = []
for format, field in structure:
self.format += format
self.fields.append(field)
vars(self)[field] = None
That avoids the triple iteration. The vars(self) call is unnecessary,
I just think it looks cleaner. :)
David.
More information about the Python-list
mailing list