Mr.SpOOn <[EMAIL PROTECTED]> writes: > class foo: > def __init__(self, a, b): > self.a = a > self.b = b > > @classmethod > def from_string(self, ..): > ... > ... > > What I mean is: I can't use anymore __init__ as the default > constructor, but I always have to specify the way I'm creating my > object. Am I right? I'm asking just to be sure I have understood.
Yes, that's what the above design requires. You code ‘foo.__init__’ for the common use case, and create ‘foo.from_bar’ classmethod factory functions for other cases. The caller then needs to specify which case is being requested. -- \ “I was in the first submarine. Instead of a periscope, they had | `\ a kaleidoscope. ‘We're surrounded.’” —Steven Wright | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list