Enums: making a single enum

Chris Angelico rosuav at gmail.com
Sat May 26 04:14:08 EDT 2018


On Sat, May 26, 2018 at 6:00 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> Actually I don't really need all the features of Enums, I might just
> define my own class:
>
>
> class Maybe:
>      def __repr__(self):
>          return "Maybe"
>
> Maybe = Maybe()
>
>
>
> I wish there was a simpler way to define symbols with identity but no
> state or behaviour...

You DO have behaviour though - the repr is a behaviour of that object.
So what you have there (reusing the name for the instance) seems
decent to me.

ChrisA



More information about the Python-list mailing list