Rick Giuly <[EMAIL PROTECTED]> writes:

> Hello All,

Hello,

> Why is python designed so that b and c (according to code below)
> actually share the same list object? It seems more natural to me that
> each object would be created with a new list object in the points
> variable.
>
> class Blob:
>     def __init__(self, points=[]):
>         self._points = points
>
>
> b = Blob()
> c = Blob()
>
> b._points.append(1)
> c._points.append(2)
>
> print b._points
>
> # this will show that b._points is the same object as c._points

This is probably the MFAQ (Most FAQ)!

Have a look in http://www.python.org/doc/faq/ (I can't point at the
question as my internet pipes to the US are very rusty this morning)

HTH

-- 
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to