Q: Duplicating Objects ... HOW ???

phil hunt philh at comuno.freeserve.co.uk
Sun Jul 8 18:42:35 EDT 2001


On Sun, 8 Jul 2001 16:29:59 -0400, Steve Holden <sholden at holdenweb.com> wrote:
>"Steve Holden" <sholden at holdenweb.com> wrote in message
>news:Uh327.14798$i8.1312190 at e420r-atl3.usenetserver.com...
>> "Alex" <new_name at mit.edu> wrote in message
>> news:etd7kxjcp8x.fsf at pickled-herring.mit.edu...
>> >
>> > You may be happier in the long run keeping the sequence of test objects
>> > in a sequence, like a list.  You could do something like this:
>> >
>> > import copy
>> > test_list = [copy.copy(obj) for obj in 20*[test]]
>> >
>> Or, possibly, in a dictionary:
>>
>> dict = {}
>> for i in range(1,21):
>>     dict[test+str(i)] = copy.copy(obj)
>>
>Sorry, read that last as
>
>    dict["test"+str(i)] = copy.copy.(obj)

You're not haviong much luck with the typos, are you?

-- 
## Philip Hunt ## philh at comuno.freeserve.co.uk ##







More information about the Python-list mailing list