Pierre Barbier de Reuille a écrit :
Antoon Pardon a écrit :
Well I find this a confusing behaviour on python's part. The fact
that instance.field can mean something different, depending on
where in a statement you find it, makes the behaviour inconsistent.
I know people in general here are against
Antoon Pardon a écrit :
Well I find this a confusing behaviour on python's part. The fact
that instance.field can mean something different, depending on
where in a statement you find it, makes the behaviour inconsistent.
I know people in general here are against declarations, but declarations
could
>
> Well I find this a confusing behaviour on python's part. The fact
> that instance.field can mean something different, depending on
> where in a statement you find it, makes the behaviour inconsistent.
>
> I know people in general here are against declarations, but declarations
> could IMO provi
Tim Daneliuk wrote:
>I am a bit confused. I was under the impression that:
>
> class foo(object):
> x = 0
> y = 1
>
> means that x and y are variables shared by all instances of a class.
> But when I run this against two instances of foo, and set the values
> of x and y, they are indeed unique to
Tim Daneliuk wrote:
I am a bit confused. I was under the impression that:
class foo(object):
x = 0
y = 1
means that x and y are variables shared by all instances of a class.
What it actually does is define names with the given values *in the
class namespace*.
But when I run this against
On Thu, 13 Jan 2005 08:56:10 -0500, Peter Hansen <[EMAIL PROTECTED]> wrote:
> Simon, it's really not about mutability at all. You've changed
> the example,
Err, there *wasn't* an example, not really. The OP just mentioned
'setting the values' of instance members. That *can* mean name
binding, bu
Simon Brunning wrote:
On 13 Jan 2005 07:18:26 EST, Tim Daneliuk <[EMAIL PROTECTED]> wrote:
But you are being mislead by the fact that integers are immutable.
'spam.eggs = 2' is *creating* an instance member - there wasn't one
before. Have a look at what happens with a mutable object:
Simon, it's re
Op 2005-01-13, harold fellermann schreef <[EMAIL PROTECTED]>:
> Hi Tim,
>
> If you have
>
> class Foo(object) :
> x = 0
> y = 1
>
> foo = Foo()
>
> foo.x # reads either instance or class attribute (class in this case)
>
> foo.x = val # sets an instance attribute (because foo is instance
Tim Daneliuk wrote:
> I am a bit confused. I was under the impression that:
>
> class foo(object):
> x = 0
> y = 1
>
> means that x and y are variables shared by all instances of a class.
> But when I run this against two instances of foo, and set the values
> of x and y, they are indeed unique
Op 2005-01-13, Simon Brunning schreef <[EMAIL PROTECTED]>:
> On 13 Jan 2005 07:18:26 EST, Tim Daneliuk <[EMAIL PROTECTED]> wrote:
>> I am a bit confused. I was under the impression that:
>>
>> class foo(object):
>> x = 0
>> y = 1
>>
>> means that x and y are variables shared by a
Hi Tim,
If you have
class Foo(object) :
x = 0
y = 1
foo = Foo()
foo.x # reads either instance or class attribute (class in this case)
foo.x = val # sets an instance attribute (because foo is instance not
class)
Foo.x = val # sets a class attribute
foo.__class.__x = val
On 13 Jan 2005 07:18:26 EST, Tim Daneliuk <[EMAIL PROTECTED]> wrote:
> I am a bit confused. I was under the impression that:
>
> class foo(object):
> x = 0
> y = 1
>
> means that x and y are variables shared by all instances of a class.
> But when I run this against two instances
I am a bit confused. I was under the impression that:
class foo(object):
x = 0
y = 1
means that x and y are variables shared by all instances of a class.
But when I run this against two instances of foo, and set the values
of x and y, they are indeed unique to the *instance* rather
13 matches
Mail list logo