Frustrated with scopes

andrew cooke andrew at acooke.org
Tue Aug 11 22:13:39 EDT 2009


Is there a way to make this work (currently scope and join are
undefined at runtime when the inner class attributes are defined):

class _StreamFactory(object):

    @staticmethod
    def __call__(lines, source, join=''.join):

        class Line(object):

            __source = source
            __join = join
[...]

I can get something working by bouncing through global values, but it
looks awful and I think it's a source of a bug due too values being
redefined.

Thanks,
Andrew



More information about the Python-list mailing list