How to copy class objects?

Max Møller Rasmussen maxm at normik.dk
Fri Feb 9 05:32:56 EST 2001


From: matthias.oberlaender at daimlerchrysler.com

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

Why not just:

class X:

  def __init__(self, scratchdir):
    self.scratchdir = scratchdir

  <blabla    (methods using scratchdir)>

first = X('/temp/')
Xnew = X('/some/where/else')

regards Max M




More information about the Python-list mailing list