Re: Scoping rules for class definitions

2014-04-08 Thread Rotwang
On 04/04/2014 19:55, Ian Kelly wrote: On Fri, Apr 4, 2014 at 12:37 PM, Rotwang wrote: Hi all. I thought I had a pretty good grasp of Python's scoping rules, but today I noticed something that I don't understand. Can anyone explain to me why this happens? x = 'global' def f1(): x = 'loca

Re: Scoping rules for class definitions

2014-04-04 Thread Ian Kelly
On Fri, Apr 4, 2014 at 12:37 PM, Rotwang wrote: > Hi all. I thought I had a pretty good grasp of Python's scoping rules, but > today I noticed something that I don't understand. Can anyone explain to me > why this happens? > x = 'global' def f1(): > x = 'local' > class C: >

Scoping rules for class definitions

2014-04-04 Thread Rotwang
Hi all. I thought I had a pretty good grasp of Python's scoping rules, but today I noticed something that I don't understand. Can anyone explain to me why this happens? >>> x = 'global' >>> def f1(): x = 'local' class C: y = x return C.y >>> def f2(): x = 'local' cl