Re: [Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Mark Lawrence via Python-Dev
On 21/04/2017 16:03, Guyzmo via Python-Dev wrote: On Fri, Apr 21, 2017 at 11:47:24AM +0200, Justus Schwabedal wrote: At least I think it's a bug. Maybe it's a feature.. it's indeed a feature. I possibly found a bug in class __init__ and would like to fix it technically, it's a method. Mor

Re: [Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Antoine Rozo
And it is not related to __init__ method. You have the same behaviour with any other function or method. >>> def append_to_list(item, l=[]): ... l.append(item) ... return l ... >>> append_to_list(1) [1] >>> append_to_list(2) [1, 2] 2017-04-21 17:18 GMT+02:00 Manolis Mavrofidis : > In a n

[Python-Dev] Summary of Python tracker Issues

2017-04-21 Thread Python tracker
ACTIVITY SUMMARY (2017-04-14 - 2017-04-21) Python tracker at http://bugs.python.org/ To view or respond to any of the issues listed below, click on the issue. Do NOT respond to this message. Issues counts and deltas: open5882 ( -7) closed 36004 (+64) total 41886 (+57) Open issues wit

Re: [Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Manolis Mavrofidis
In a nutshell. You create two instances and you assign the same list to both of them which you instantiate when you run your code. >>> id(spam_1.list) 4530230984 # <- Here >>> id(spam_2.list) 4530230984 # <- Here >>> id(spam_1) 4530231632 # Nice unique instance >>> id(spam_2) 4530231200 # Nice uniq

Re: [Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Max Zettlmeißl
On 21 April 2017 at 12:09, Justus Schwabedal wrote: > I possibly found a bug in class initialization and would like to fix it. > > Here comes the bug-producing example: > > `class Foo: > def __init__(self, bar=[]): > self.list = bar > > spam_1 = Foo() > spam_2 = Foo() > > spam_1.list.a

Re: [Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Guyzmo via Python-Dev
On Fri, Apr 21, 2017 at 11:47:24AM +0200, Justus Schwabedal wrote: > At least I think it's a bug. Maybe it's a feature.. it's indeed a feature. > I possibly found a bug in class __init__ and would like to fix it technically, it's a method. More precisely, it's the constructor method. > So I'm

Re: [Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Paul Moore
This is correct behaviour. I would suggest that you post this to python-list for a full discussion of what's going on here, but basically the default value for argument bar of __init__ is created at class creation time, and then reused for every instance. This is a common mistake made by newcomers,

[Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Justus Schwabedal
Hi everyone, I possibly found a bug in class initialization and would like to fix it. Because it's my first journey to core-dev, I would really appreciate the help of a mentor that I may ask a few questions to get me up to speed. To my person, I have previously worked on larger projects in python

[Python-Dev] Possible bug in class-init, lookin for mentors

2017-04-21 Thread Justus Schwabedal
Hi everyone, I possibly found a bug in class __init__ and would like to fix it. So I'm looking for a mentor to help me. `class Foo: def __init__(self, bar=[]): self.list = bar spam_1 = Foo() spam_2 = Foo() spam_1.list.append(42) print(spam_2.list)` At least I think it's a bug. Ma