Re: Inserting class namespace into method scope

2010-11-21 Thread Emile van Sebille
On 11/20/2010 4:59 PM Steven D'Aprano said... On Sun, 21 Nov 2010 08:59:30 +1100, Ben Finney wrote: C'mon, Steven, you know the drill. If you want us to help you solve a problem, don't start with “I want to use this behaviour that seems loony, and I won't say why”. Instead, help us by telling u

Re: Inserting class namespace into method scope

2010-11-20 Thread Ben Finney
Steven D'Aprano writes: > I have a bunch of related functions and objects which are private to a > module, with a single public function that acts as the API to those > functions. I'd like to have these private functions in a namespace, > separate from the rest of the module. Ignore the fact that

Re: Inserting class namespace into method scope

2010-11-20 Thread Steven D'Aprano
On Sun, 21 Nov 2010 08:59:30 +1100, Ben Finney wrote: > C'mon, Steven, you know the drill. If you want us to help you solve a > problem, don't start with “I want to use this behaviour that seems > loony, and I won't say why”. Instead, help us by telling us what problem > you're trying to solve. W

Re: Inserting class namespace into method scope

2010-11-20 Thread Ben Finney
Steven D'Aprano writes: > I also understand that the usual way of getting this would be to > return self.x or self.__class__.x from method, instead of x. Again, > normally I would do this. > > But in this specific case I have reasons for wanting to avoid both of > the normal behaviours. Do not ju

Re: Inserting class namespace into method scope

2010-11-20 Thread Emile van Sebille
On 11/20/2010 6:59 AM Steven D'Aprano said... I find myself having need of a class where the class scope is included in the scope of methods in the class. A simple example from Python 3.1: x = "outside" class Magic: x = "inside" def method(self): return x I would like Magic

Re: Inserting class namespace into method scope

2010-11-20 Thread Günther Dietrich
Steven D'Aprano wrote: >I find myself having need of a class where the class scope is included in >the scope of methods in the class. A simple example from Python 3.1: > >x = "outside" > >class Magic: >x = "inside" >def method(self): >return x > > >I would like Magic().method() t

Re: Inserting class namespace into method scope

2010-11-20 Thread Duncan Booth
Steven D'Aprano wrote: > But in this specific case I have reasons for wanting to avoid both of > the normal behaviours. Do not judge me, please accept that I have a > good reason for wanting this, or at least allow me to shoot myself in > the foot this way *wink*. In Python 3, is there some way t

Inserting class namespace into method scope

2010-11-20 Thread Steven D'Aprano
I find myself having need of a class where the class scope is included in the scope of methods in the class. A simple example from Python 3.1: x = "outside" class Magic: x = "inside" def method(self): return x I would like Magic().method() to return "inside" rather than "outsid