[Tutor] Challenge supporting custom deepcopy with inheritance

Alan Gauld alan.gauld at btinternet.com
Tue Jun 2 01:45:30 CEST 2009


"Kent Johnson" <kent37 at tds.net> wrote

> But its two lines not one... :-(

Why not this?

class C:
  def __init__(self): pass

  @staticmethod
  def LoadFromFile(fname, count):
    c = C()
    # init c from the file
    return c

and similar for Create(). Client code is one line:
c = C.LoadFromFile(fn, cnt)

Kent
_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor




More information about the Tutor mailing list