Sorry about the title, I'm not sure how to word this question in a more general sense. I'm working on a brainfuck parser. The language has 8 kinds of tokens, which I currently represent with the following classes:
# Types of lexical tokens
class Token: pass
class IncPtrToken(Token): pass
class DecPtrToken(Token): pass
class IncByteToken(Token): pass
class DecByteToken(Token): pass
class OutputByteToken(Token): pass
class InputByteToken(Token): pass
class LoopStartToken(Token): pass
class LoopEndToken(Token): pass
In another language I would probably use an enumeration to represent the different types, but this seems like a reasonable alternative in Python.
I have read that there are other ways of representing enums in Python, but I think this style is suitable because some of these entities may carry additional data with them. For example, when representing types of nodes in a parser, a node like a loop would contain a member with the nodes inside the loop.