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
[...]

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

Supply us with just enough source code to actually try it, give the full error message including traceback, and tell us what you expected to see. Also tell us Python version (sys.version)

So far you've done none of these. When I try the following, I get no errors, using Python 2.6.2


class _StreamFactory(object):

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

       class Line(object):

           __source = source
           __join = join
       return Line()


fact = _StreamFactory()
obj = fact(43, "name.txt")
print obj


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to