Re: [Tutor] Baffling problem with a list of objects sharing a property

2016-05-26 Thread Danny Yoo
> They are. You've stiumbled on one of those Python peculiarities of > implementation that can be useful and annoying in equal measure. > >> class Test(object): >> def __init__(self, name, paths=[]): >> self.name = name >> self.paths = paths > > When you give a function/method a default value

Re: [Tutor] Baffling problem with a list of objects sharing a property

2016-05-25 Thread Alan Gauld via Tutor
On 25/05/16 17:05, Alex Hall wrote: > Python for a while so eventually unsubscribed. Welcome back Alex :-) > Now I'm using Python for work, and have run into a problem that has me > baffled. It's as though a bunch of class instances in a list are sharing a > single property. They are. You've s

Re: [Tutor] Baffling problem with a list of objects sharing a property

2016-05-25 Thread Peter Otten
Alex Hall wrote: > class Test(object): > def __init__(self, name, paths=[]): https://docs.python.org/2/faq/programming.html#why-are-default-values-shared-between-objects ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription o

[Tutor] Baffling problem with a list of objects sharing a property

2016-05-25 Thread Alex Hall
Hello all, I've used Python off and on for years, and consider myself pretty good with it. I was on this list quite a while ago and learned a lot, but hadn't used Python for a while so eventually unsubscribed. Now I'm using Python for work, and have run into a problem that has me baffled. It's as