Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
> Right now, you really gotta jump through hoops > in some cases if you only want to use __new__ > and don't care about __init__ I'm now sure I see the difficulty. It is easy to define a classes with __new__ and without __init__: >>> class A: def __new__(cls, *args): print('New called with', cls, 'and', args) return object.__new__(cls) >>> a = A(10, 20, 30) New called with <class '__main__.A'> and (10, 20, 30) >>> isinstance(a, A) True > Like __hash__, allow setting MyClass.__init__ to None FWIW, the API for hashing being set-to-None wasn't done because we like it (there a numerous downsides). It was done because we needed hashing to be on by default and there needed to be a way to turn it off. The downsides are that it confuses users, it is hard to teach and remember, and it adds a branch to various APIs which would then need to test for None. Instead, we prefer the pattern of having object() provide a default dummy method that either does nothing or gives up (like object.__init__ or the various rich comparison methods for object). This simplifies downstream code than doesn't have to check for a rare special case. ---------- assignee: -> rhettinger nosy: +rhettinger _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34314> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com