Message344661
The point is, constructing via __new__ and initializing via __init__ are two mechanisms that aren't really orthogonal, and various heuristics are trying to guess whether the arguments you call your class with are meant for __new__ or for __init__. [Usually, immutable objects are __new__able, and mutable ones are __init__able -- and crucially, objects are usually not both. For example, list is __init__able, but tuple is __new__able.] Those heuristics assume you won't have both __init__ and __new__ implemented on your object. It mostly works if you have a hierarchy of __new__able objects, or a hierarchy of __init__able objects, but as you noticed, it usually breaks if you have an __init__able class derived from a __new__able one, or vice versa. If you're really trying for a most general solution, please note that __init__ is redundant: everything __init__ does can be done with __new__ (but not vice versa). So, you should just have a hierarchy of __new__able classes. |
|
| Date |
User |
Action |
Args |
| 2019-06-05 01:30:53 | veky | set | recipients:
+ veky, rhettinger, SilentGhost, alexey-muranov |
| 2019-06-05 01:30:53 | veky | set | messageid: <1559698253.09.0.0774094806428.issue36827@roundup.psfhosted.org> |
| 2019-06-05 01:30:53 | veky | link | issue36827 messages |
| 2019-06-05 01:30:52 | veky | create | |
|