This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients facundobatista, gvanrossum, jyasskin, mark.dickinson, ncoghlan, rhettinger
Date 2008-02-12.12:07:35
SpamBayes Score 0.0008833773
Marked as misclassified No
Message-id <1202818121.91.0.0942689383199.issue1682@psf.upfronthosting.co.za>
In-reply-to
Content
I mentioned my dislike of the classmethod->staticmethod change on the
python-checkins list, but given the lack of response there, I figure I
should bring it up here. It is well established that the way to
implement an alternate constructor in Python is to write a classmethod.
This means the alternate constructor will behave in a way similar to
__new__: invocation via a subclass will result in an instance of that
subclass rather than of the base type.

Now, this does usually mean the parent class is placing certain
expectations on the signature of the subclass constructor. However, this
is a pretty common Python idiom, and a lot friendlier than coercing the
result to the base type. It makes the common case (constructor signature
unchanged or at least compatible) simple, while still permitting the
rarer case of changing the signature in an incompatible way (by
overriding the class methods as well as the __new__ and __init__ methods)

If you want to make this more convenient for users that do want to
subclass and change the constructor signature, the expected interface
can be factored out to a single method, similar to the way it is done
for collections.Set and its _from_iterable class method (i.e. if a Set
subclass constructor doesn't accept an iterable directly, it can just
override _from_iterable to adapt the supplied iterable to the new
interface).
History
Date User Action Args
2008-02-12 12:08:42ncoghlansetspambayes_score: 0.000883377 -> 0.0008833773
recipients: + ncoghlan, gvanrossum, rhettinger, facundobatista, mark.dickinson, jyasskin
2008-02-12 12:08:41ncoghlansetspambayes_score: 0.000883377 -> 0.000883377
messageid: <1202818121.91.0.0942689383199.issue1682@psf.upfronthosting.co.za>
2008-02-12 12:07:36ncoghlanlinkissue1682 messages
2008-02-12 12:07:35ncoghlancreate