[Tutor] overriding instance attributes with keywords
eryksun
eryksun at gmail.com
Tue Aug 14 20:55:08 CEST 2012
On Tue, Aug 14, 2012 at 2:25 PM, Matt Gregory
<matt.gregory at oregonstate.edu> wrote:
>
> Thanks to you both for really helpful advice. A quick follow-up question -
> would you want to create a deepcopy of obj1 in the above example if your
> obj1 contained other objects? I think that Steven's class method gets
> around this?
Chances are you either want a shallow copy or to use a special
constructor as Steven wrote. For example, consider an object with a
file attribute based on a filename argument. Say for example it's for
an MP3 file and the object reads in the ID3 tags in __init__. If you
want a new instance based on the same arguments, except for a
different MP3 file, then you don't want a copy or a deepcopy.
More information about the Tutor
mailing list