[Python-Dev] Proper way to specify that a method is not defined for a type (original) (raw)
Ethan Furman ethan at stoneleaf.us
Tue Jun 7 13:37:58 EDT 2016
- Previous message (by thread): [Python-Dev] PEP 492: __aiter__ should return async iterator directly instead of awaitable
- Next message (by thread): [Python-Dev] Proper way to specify that a method is not defined for a type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
For binary methods, such as add, either do not implement or return NotImplemented if the other operand/class is not supported.
For non-binary methods, simply do not define.
Except for subclasses when the super-class defines hash and the subclass is not hashable -- then set hash to None.
Question:
Are there any other methods that should be set to None to tell the run-time that the method is not supported? Or is this a general mechanism for subclasses to declare any method is unsupported?
--
Ethan
- Previous message (by thread): [Python-Dev] PEP 492: __aiter__ should return async iterator directly instead of awaitable
- Next message (by thread): [Python-Dev] Proper way to specify that a method is not defined for a type
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]