[Tutor] Variable scope for class?

2007-08-30 Thread Orest Kozyar
I'm trying to follow the example listed in the wiki at http://www.sqlalchemy.org/trac/wiki/UsageRecipes/UniqueObject regarding the use of a metaclass. What I don't understand is how the metaclass (EntitySingleton) has access to the variable ctx which is instantinated outside the scope of the

Re: [Tutor] Variable scope for class?

2007-08-30 Thread Kent Johnson
Orest Kozyar wrote: I'm trying to follow the example listed in the wiki at http://www.sqlalchemy.org/trac/wiki/UsageRecipes/UniqueObject regarding the use of a metaclass. What I don't understand is how the metaclass (EntitySingleton) has access to the variable ctx which is instantinated

Re: [Tutor] Variable scope for class?

2007-08-30 Thread Dave Kuhlman
On Thu, Aug 30, 2007 at 06:02:12PM -0400, Orest Kozyar wrote: I'm trying to follow the example listed in the wiki at http://www.sqlalchemy.org/trac/wiki/UsageRecipes/UniqueObject regarding the use of a metaclass. What I don't understand is how the metaclass (EntitySingleton) has access to

Re: [Tutor] Variable scope for class?

2007-08-30 Thread Kent Johnson
Dave Kuhlman wrote: So far so good. But, here is the one I do not understand. G1 = 111 class A(object): G1 = 222 def show(self): print G1 def test(): a = A() a.show() test() But, when I run this I see 111, not 222.

Re: [Tutor] Variable scope for class?

2007-08-30 Thread Alan Gauld
Dave Kuhlman [EMAIL PROTECTED] wrote Actually, the particular edition of Alan's book that I have is old enough so that it does not discuss the Enclosing namespace, which came later to Python. The enclosing namespace not make a difference in your example, but does in mine. The paper book is