Generator metadata/attributes at at
Thu Jan 8 12:14:28 CET 2009

Thanks folks.  Will write my own class....  Andrew

PS So for the record, this works and isn't as ugly/verbose as I was

class TaggedWrapper():

    def __init__(self, generator, logMixin, stream):
        self.__generator = generator
        self.__tag = '%s@%s' % (logMixin.describe(), stream)
        logMixin._debug('Created %s' % self)

    def __next__(self):
        return next(self.__generator)

    def __str__(self):
        return self.__tag

def tag_generator(f):
    Log the generator.
    def call(self, stream):
        return TaggedWrapper(f(self, stream), self, stream)
    return call

More information about the Python-list mailing list