[issue34314] Like __hash__, allow setting MyClass.__init__ to None to prevent it being called by type.__call__

2018-08-03 Thread Raymond Hettinger
Change by Raymond Hettinger : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

[issue34314] Like __hash__, allow setting MyClass.__init__ to None to prevent it being called by type.__call__

2018-08-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Setting __hash__ to None doesn't do what you think. It doesn't prevent __hash__ from being called by hash(), instead it produces a TypeError. >>> class A: __hash__ = None ... >>> hash(A()) Traceback (most recent call last): File "", line 1, in

[issue34314] Like __hash__, allow setting MyClass.__init__ to None to prevent it being called by type.__call__

2018-08-01 Thread Raymond Hettinger
Raymond Hettinger 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:

[issue34314] Like __hash__, allow setting MyClass.__init__ to None to prevent it being called by type.__call__

2018-08-01 Thread Dan Snider
New submission from Dan Snider : Right now, you really gotta jump through hoops in some cases if you only want to use __new__ and don't care about __init__ (is there ever a time where you'd use both?). The problem originates in type.__call__. I'm attaching a full Python implementation of