Q: Duplicating Objects ... HOW ???

Steve Holden sholden at holdenweb.com
Sun Jul 8 16:29:59 EDT 2001


"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)







More information about the Python-list mailing list