List of lists surprising behaviour

bart.c bartc at freeuk.com
Fri Jun 18 06:00:39 EDT 2010


Benjamin Kaplan wrote:
> On Thu, Jun 17, 2010 at 4:20 PM, bart.c <bartc at freeuk.com> wrote:

>> I don't know how Python does things, but an object should either
>> specify a special way of duplicating itself, or lend itself to some
>> standard way of doing so. (So for a list, it's just a question of
>> copying the data in the list, then recursively duplicating each new
>> element..)

> It's the recursively duplicating each element that's the problem. How
> do you know when to stop?

When you reach a primitive object (one not comprising other objects). (I 
don't know if Python allows circular references, but that would give 
problems anyway: how would you even print out such a list?)

-- 
Bartc 




More information about the Python-list mailing list