You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The attribute's action of an object is not correct. #49870
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2009-04-01.13:05:28.941>created_at=<Date2009-03-31.11:27:23.882>labels= ['type-bug']
title="The attribute's action of an object is not correct."updated_at=<Date2009-04-01.13:05:28.917>user='https://bugs.python.org/Yongyang'
AFAIK, This is expected behavior. myurl is a class attribute if you
want it to be different per instance you should re-initialize it in the
__init__ method. See below.
Activity
Yongyang commentedon Mar 31, 2009
The following is the test code.
The output is :
[5, 6, 7]
[5, 6, 7, 5, 6, 7]
[5, 6, 7, 5, 6, 7, 5, 6, 7]
[5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7]
[5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7]
[5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7]
[5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7]
[5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6,
7]
[5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6,
7, 5, 6, 7]
[5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6,
7, 5, 6, 7, 5, 6, 7]
The myurl of class C1 is not set to [] when a new object is created.
All objects use the same memory.
Kozyarchuk commentedon Mar 31, 2009
AFAIK, This is expected behavior. myurl is a class attribute if you
want it to be different per instance you should re-initialize it in the
__init__ method. See below.
Yongyang commentedon Apr 1, 2009
Thanks a lot!
Kozyarchuk.
I have thought the self.myurl should be the object variable, not class
variable.
The class variable really is confusing.
Why do they like that?