How to copy class objects?

matthias.oberlaender at daimlerchrysler.com matthias.oberlaender at daimlerchrysler.com
Fri Feb 9 03:53:57 EST 2001


This is the question I'd like to be answered:

Is there some easy way to copy a class object? 

Here is the background:

In order to generate classes from templates I'd prefer the following method 
over writing additional wrapper function

class X:
  
  sratchdir = "/tmp/"

  <blabla    (methods using scratchdir)>

# I want a new class Xnew differing from X in that its instances use a 
different scratch directory.
Xnew = copyclass(X)
# Now set scratchdir to something else
Xnew.scratchdir = '/home/me/tmp'


--
 ____  __  _/_/ . 
( / / ( /  / / /  

=====================================================================
Matthias Oberlaender, DaimlerChrysler AG, Research Center Ulm
FT3/AB (Information Technology / Image Understanding)
Wilhelm-Runge-Str. 11,  P.O. Box 2360,  89013 Ulm, Germany
Phone: +49 731 505 2354       Fax: +49 731 505 4113
Email: matthias.oberlaender at daimlerchrysler.com
=====================================================================




More information about the Python-list mailing list