[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Python enumerations
> While thinking about the problem, it occured to me that that classes
> could also be used as enumerations
This solution seems particularly adapted to what I want to do. And (to
my surprise), classes are hashable.
The only problem I'm encountering is the stringification of classes:
>>> class A: pass
...
>>> x = A
>>> print str(x)
__main__.A
I'd rather have it stringify as "A". Of course, I could do this:
>>> s = str(x)
>>> print s[s.rindex('.')+1:]
A
But is there a more graceful way?
--
I had picked out the theme of the baby's room and done other
things. I decided to let Jon have this.
- Jamie Cusack (of the Netherlands), whose husband Jon
finally talked her into letting him name their son Jon 2.0