Inexplicable behavior in simple example of a set in a class

Chris Rebert clp2 at rebertia.com
Sat Jul 2 21:07:49 EDT 2011


On Sat, Jul 2, 2011 at 5:46 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Sun, Jul 3, 2011 at 8:23 AM, Saqib Ali <saqib.ali.75 at gmail.com> wrote:
>> So just out of curiosity, why does it work as I had expected when the
>> member contains an integer, but not when the member contains a set?
>
> It's not integer vs set; it's the difference between rebinding and
> calling a method. It's nothing to do with object orientation; the same
> happens with ordinary variables:
<snip>
>>>> c=d=[]
>>>> c,d
> ({}, [])

Nasty typo in your pseudo-interpreter-session there...

Cheers,
Chris



More information about the Python-list mailing list