Class scoping problem...
Hans Nowak
hnowak at cuci.nl
Tue Sep 26 12:33:49 EDT 2000
On 26 Sep 00, at 17:25, Simon Brunning wrote:
> I'm having a bit of a problem with scoping within a class. Something similar
> is mentioned in Andrew Kuchling's 'Python Warts' page, but I can't find a
> workaround.
>
> Take the following:
>
> class Foo:
>
> def __init__(self):
> self.bar = 1
>
> def baz(self):
>
> def quix():
> return self.bar
>
> return quix()
>
> foo = Foo()
>
> print foo.baz()
OK, so why not try something like this:
def baz(self):
return self.quix()
def quix(self):
return self.bar
I suppose you have thought about that already, but I'm curious to know why
this would not be a solution to your problem.
Blessed be,
--Hans Nowak (zephyrfalcon at hvision.nl)
You call me a masterless man. You are wrong. I am my own master.
May Bill Gates ram your soul!
More information about the Python-list
mailing list