...and really means this...
class C:
x = 1
def f(self,y): return T.x + y
I don't understand what T is. Did you mean C?
Yes, I meant C. Thanks.
If so, you are wrong. self.x is not the same as class.x due to
inheritance rules. Consider one example:
example snipped see thread/
I think a big part of the problem is that the scoping rules in Python
are inconsistent because classes are a different kind of object. An
example helps:
This works:
x = 1
def f(y): return y + x
This works:
def f():
x = 1
def g(y): return x + y
return g(2)
But this doesn't work...
class
On Feb 27, 2010, at 6:57 PM, dontspamleo wrote:
http://bioscreencastwiki.com/Python_Variable_scope_gymnastics
Broken link:
Site settings could not be loaded
We were unable to locate the API to request site settings. Please see below for
debugging information.
HTTP Response Status Code:
On Sat, 27 Feb 2010 15:57:15 -0800, dontspamleo wrote:
I think a big part of the problem is that the scoping rules in Python
are inconsistent because classes are a different kind of object. An
example helps:
[...]
But this doesn't work...
class C:
x = 1
def f(self,y): return x + y
Hi Arnaud et al,
Here is the link to the bug report from which the discussion in PEP
289 was extracted:
http://bugs.python.org/issue872326
It looks like they were fixing a bunch of bugs and that this
discussion was one of the many in that thread.
Here is another post which points to the core
dontspamleo dontsendleos...@gmail.com writes:
Hi Arnaud et al,
Here is the link to the bug report from which the discussion in PEP
289 was extracted:
http://bugs.python.org/issue872326
It looks like they were fixing a bunch of bugs and that this
discussion was one of the many in that
* Nomen Nescio:
Hello,
Can someone help me understand what is wrong with this example?
class T:
A = range(2)
B = range(4)
s = sum(i*j for i in A for j in B)
It produces the exception:
type 'exceptions.NameError': global name 'j' is not defined
Which Python implementation are you
On Feb 24, 5:52 am, Nomen Nescio nob...@dizum.com wrote:
Hello,
Can someone help me understand what is wrong with this example?
class T:
A = range(2)
B = range(4)
s = sum(i*j for i in A for j in B)
It produces the exception:
type 'exceptions.NameError': global name 'j' is not
On Feb 24, 12:21 pm, Alf P. Steinbach al...@start.no wrote:
* Nomen Nescio:
Hello,
Can someone help me understand what is wrong with this example?
class T:
A = range(2)
B = range(4)
s = sum(i*j for i in A for j in B)
It produces the exception:
type
Nomen Nescio wrote:
Hello,
Can someone help me understand what is wrong with this example?
class T:
A = range(2)
B = range(4)
s = sum(i*j for i in A for j in B)
It produces the exception:
type 'exceptions.NameError': global name 'j' is not defined
It's due to scoping rules for
Hi Folks,
Thanks everyone for the great contributions! I understand this better
now. The distinction between a shorthand for a function definition and
a shorthand for a loop iteration is crucial.
Also: thanks for pointing out the even the list comprehension doesn't
work in py3. That was
dontspamleo dontsendleos...@gmail.com writes:
@Arnaud: I tried to find your earlier post -- googled Arnaud lambda
-- but couldn't.
I remembered after posting that I sent this to python-ideas. Here is the
first message in the thread:
12 matches
Mail list logo