Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
It can be useful in some uncommon use cases to make some, let's say, "magic" classes. For example, the enum module in the stdlib makes use of __new__ to create enum classes.
in the standard library I know of at least 3 use cases: fractions.Fraction (because it should be immutable they use new instead), pathlib.Path (as a dispatcher for your OS specific path class) and for metaclases shenanigans in abc.ABCMeta, there is also pure python version of it the module _py_abc.ABCMeta check those out in your local installation, I used that one as example to make my own metaclass one day that I was interested in such thing