In #Python, @classmethod can used to create alternate constructors for making objects in other ways. Here's a simple example:
=> More informations about this toot | More toots from nedbat@hachyderm.io
@nedbat Importantly this is better than staticmethod because the cls parameter makes it work with subclassing
=> More informations about this toot | More toots from anselmschueler@ieji.de
@nedbat In my libraries I've used the convention for these alternative constructors to always start with 'mk'--typically with a description so yours would be "mk_random".
=> More informations about this toot | More toots from bonsai@hachyderm.io This content has been proxied by September (ba2dc).Proxy Information
text/gemini