trouble with generators

2007-05-10 Thread Hans-Peter Jansen
Hi Pythonistas, I'm stuck in a maze of new style classes and generators. While I love the concepts, I obviously didn't grok them throughout. I'm trying to generate a bunch of similar classes, where some are contained in list attributes of others, e.g.: class A: def __init__(self):

Re: trouble with generators

2007-05-10 Thread Diez B. Roggisch
Hans-Peter Jansen schrieb: Hi Pythonistas, I'm stuck in a maze of new style classes and generators. While I love the concepts, I obviously didn't grok them throughout. I'm trying to generate a bunch of similar classes, where some are contained in list attributes of others, e.g.: All

Re: trouble with generators

2007-05-10 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Hans-Peter Jansen wrote: class Gen(object): def records(self, cls): for i in range(3): setattr(cls, id, %s%s % (cls.__doc__, i)) yield cls […] class GenA(Gen): def __init__(self): self.genB = GenB() def

Re: trouble with generators

2007-05-10 Thread Hans-Peter Jansen
Hi Diez, first, thanks for your comprehensive answer. Diez B. Roggisch wrote: Hans-Peter Jansen schrieb: I'm trying to generate a bunch of similar classes, where some are contained in list attributes of others, e.g.: All your code below shows that you don't create classes, but

Re: trouble with generators

2007-05-10 Thread Hans-Peter Jansen
Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], Hans-Peter Jansen wrote: class Gen(object): def records(self, cls): for i in range(3): setattr(cls, id, %s%s % (cls.__doc__, i)) yield cls […] class GenA(Gen): def __init__(self):