Frustrated with scopes

andrew cooke andrew at acooke.org
Wed Aug 12 07:51:37 EDT 2009


On Aug 12, 7:49 am, andrew cooke <and... at acooke.org> wrote:
> 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...).

ie when the __call__ method is invoked on an instance of
_StreamFactory.

> Andrew




More information about the Python-list mailing list