On Thu, 14 Jul 2005 08:38:36 +0200, Peter Otten wrote:
> Maybe, after a little renaming you can see it yourself:
>
> class SomeClass:
> def __init__(self, default_contents=[]):
> # make a copy of default_contents that is # kept in a SomeClass
> instance
> self.contents
Simon Morgan wrote:
> Can somebody please explain to me why:
>
> class SomeClass:
> def __init__(self, contents=[]):
> self.contents = contents[:]
> def add(self, element):
> self.contents.append(element)
>
> when called a second time (i.e. to create a new instance of a S
Hi,
Can somebody please explain to me why:
class SomeClass:
def __init__(self, contents=[]):
self.contents = contents[:]
def add(self, element):
self.contents.append(element)
when called a second time (i.e. to create a new instance of a SomeClass
object) results in self.c