<br><br><div class="gmail_quote">On Fri, Aug 28, 2009 at 9:49 AM, kj <span dir="ltr"><no.email@please.post></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
Miles Kaufmann <<a href="mailto:milesck@umich.edu">milesck@umich.edu</a>> writes:<br></div>
<br>
>...because the suite<br>
<div class="im">>namespace and the class namespace would get out of sync when different<br>
>objects were assigned to the class namespace:<br>
<br>
>class C:<br>
>   x = 1<br>
>   def foo(self):<br>
>       print x<br>
>       print self.x<br>
<br>
> >>> o = C()<br>
> >>> o.foo()<br>
>1<br>
>1<br>
> >>> o.x = 2<br>
> >>> o.foo()<br>
>1<br>
>2</div></blockquote><div><br>I haven't tested either codes, but that isn't "out of sync". Your x = 1 is a static variable, and shared between all isntances of class C.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
But this unfortunate situation is already possible, because one<br>
can already define<br>
<div class="im"><br>
class C:<br>
   x = 1<br>
   def foo(self):<br>
</div>       print C.x<br>
       print self.x<br>
<br>
which would lead to exactly the same thing.<br>
</blockquote><div><br>It works because you're simply explicitly referring to the class's local scope, which leads to the same result.<br><br>Again, that's just my understanding of the implementation.<br><br>Cheers,<br>
Xav <br></div></div><br>