In message [EMAIL PROTECTED], Terry
Reedy wrote:
[EMAIL PROTECTED] wrote:
class Outer:
def __init__(self):
class Inner:
def __init__(self): pass
a = Inner()
This create a duplicate Inner class object for every instance of Outer,
which is almost certainly not
I ran into a weird behavior with lexical scope in Python. I'm hoping
someone on this forum can explain it to me.
Here's the situation: I have an Outer class. In the Outer class, I
define a nested class 'Inner' with a simple constructor. Outer's
constructor creates an instance of Inner. The code
mrstevegross [EMAIL PROTECTED] writes:
I ran into a weird behavior with lexical scope in Python. I'm hoping
someone on this forum can explain it to me.
Here's the situation: I have an Outer class. In the Outer class, I
define a nested class 'Inner' with a simple constructor. Outer's
def __init__(self, Inner=Inner):
Ok, the Inner=Inner trick works. What the heck does that do, anyway?
I've never seen that formulation.
--Steve
--
http://mail.python.org/mailman/listinfo/python-list
def __init__(self, Inner=Inner):
Steve Ok, the Inner=Inner trick works. What the heck does that do, anyway?
Steve I've never seen that formulation.
Understanding that will put you on the path to scoping enlightenment.
Consider when that default assignment is established and how that
At 2008-11-06T16:57:39Z, mrstevegross [EMAIL PROTECTED] writes:
class Outer:
class Inner:
def __init__(self):
pass
def __init__ (self):
a = Inner()
Outer()
Try instead:
class Outer:
def __init__(self):
a = self.Inner()
--
Kirk Strauser
The Day Companies
On Nov 6, 9:57 pm, mrstevegross [EMAIL PROTECTED] wrote:
I ran into a weird behavior with lexical scope in Python. I'm hoping
someone on this forum can explain it to me.
Here's the situation: I have an Outer class. In the Outer class, I
define a nested class 'Inner' with a simple constructor
[EMAIL PROTECTED] wrote:
On Nov 6, 9:57 pm, mrstevegross [EMAIL PROTECTED] wrote:
I ran into a weird behavior with lexical scope in Python. I'm hoping
someone on this forum can explain it to me.
Here's the situation: I have an Outer class. In the Outer class, I
define a nested class 'Inner