fgmacedo / python-statemachine

Python Finite State Machines made easy.
MIT License
854 stars 84 forks source link

sm.current_state.name capitalizes the state name and replaces underscores with spaces #440

Closed v5out closed 3 months ago

v5out commented 3 months ago

Description

Using sm.current_state.name to find the current state name.

With state name "my_statename", sm.currentstate.name returns "My statename". I expected to get the same state name back as what was used. The state name comes back capitalized and with replaced with a space. .

v5out commented 3 months ago

This behavior is correct per the documentation.

fgmacedo commented 3 months ago

Hi @v5out , how are you?

You can use sm.current_state.id for the assigned class variable name, or you can explicitly pass a name as the first state constructor param and the class will use the given name instead of generating one from the identification.

As you can see here: https://github.com/fgmacedo/python-statemachine/blob/develop/statemachine%2Fstate.py#L169-L170