Frustrated with scopes

andrew cooke andrew at acooke.org
Wed Aug 12 13:49:06 CEST 2009


On Aug 12, 1:51 am, James Stroud <nospamjstroudmap... at mbi.ucla.edu>
wrote:
> andrew cooke wrote:
> > 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
> > [...]
>
> It would be helpful if you were to describe the type of behavior you expect.

Sorry, I didn't make myself clear.  When run the code gives
 NameError: name 'source' is not defined
because the class namespace blocks the function namespace (or
something...).

Andrew



More information about the Python-list mailing list