Gregory Ewing <greg.ew...@canterbury.ac.nz>: > Marko Rauhamaa wrote: >> Lexically, there is special access: >> >> class C: >> def __init__(self, some, arg): >> c = self >> class D: >> def method(self): >> access(c) >> access(some) >> access(arg) > > [...] > > you can do that without creating a new class every time you want an > instance. You just have to be *slightly* more explicit about the link > between the inner and outer instances.
By "*slightly* more explicit," do you mean more syntactic clutter? Because of course you replace inner classes and closures with top-level classes and methods of top-level classes. And of course, I would prefer not to create a class for a singleton object: class C: def __init__(self, some, arg): c = self self.d = object: def method(self): access(c) access(some) access(arg) Unfortunately, there is no such syntax in Python. Marko -- https://mail.python.org/mailman/listinfo/python-list