Closed caleb531 closed 2 years ago
@eliotwrobson What do you find hacky about it? 😅
@caleb531 Just using a class variable as a global flag to control behavior. The class is effectively a singleton, and class creation behavior no longer depends only on input parameters. But like I said, for something this simple I don't think it's really a big deal.
Something like this might actually be a standard pattern in other Python packages too, just something I haven't run into before.
Something like this might actually be a standard pattern in other Python packages too, just something I haven't run into before.
It's not any different than some python standard library configuration options, such as sys.setrecursionlimit
.
@eliotwrobson
class creation behavior no longer depends only on input parameters.
Just wanted to address this: while it is true that something outside of the input parameters can change the behavior, it is only an issue if you create an invalid automaton (which, validation or none, will produce unpredictable behavior anyway). If you always create a valid automaton, then the behavior technically does not change based on the value of this new setting.
@caleb531 that makes sense, like I said before I don't have any objections to the way that you're doing this, just something that I haven't seen a lot (mostly due to my own inexperience 😅 , and having spent too much time around functional programming purists). I think it looks good!
I've added the appropriate documentation to the README in this PR, so this configuration functionality should now be ready to merge.
Adds a new
automata.base.config
module with the following members:Config
class that is only used for instantiating theglobal_config
instance mentioned belowConfig
instance calledglobal_config
, which is referenced in theautomata.base.automaton
module.README documentation still needs to be added.
@eliotwrobson @Tagl I welcome your feedback on the code I've written so far.