typed_python icon indicating copy to clipboard operation
typed_python copied to clipboard

Alternatives should have their name in `__name__`

Open atzannes opened this issue 6 years ago • 1 comments

Currently, one can access the name of an alternative with alt.Name which is not very pythonic. It is probably better to switch to alt.__name__ instead. Besides not being pythonic, using Name is a bit risky because a user may define Name to be a member of one of the alternatives which could use to very confusing behavior.

atzannes avatar Apr 03 '19 14:04 atzannes

Actually, it might be better to use __alternative__ instead, because __name__ already has a meaning in python. And it might be preferable to keep alt.Name for backwards compatibility.

atzannes avatar Dec 11 '19 21:12 atzannes