A couple of OOPython questions

Hans Nowak hans at zephyrfalcon.org
Tue Sep 9 13:36:19 EDT 2003


Alexy Khrabrov wrote:

> Reading python books feels a bit like reading Perl books -- although
> OO is there, some fundamental questions are not illuminated, and then
> OO comes after scripting or text, as in the Cookbook!  E.g., a = b is
> a deep copy.  How do you do shallow copy?  What are the equivalent of
> copy constructors?

"a = b" is not a copy at all.  Well, I suppose you could say it copies a 
reference, but that's about it.  Assignment never copies objects, whether deep 
or shallow.

For "real" copying, use the copy module, or the .copy() method if available.

-- 
Hans (hans at zephyrfalcon.org)
http://zephyrfalcon.org/







More information about the Python-list mailing list