My Python script needs about 20 paths / filenames that share common base paths. Until now, these have been set globally, but now they need to be modified on user input:
globalbase = "thispath/"
globalvar_a = globalbase + "file.ext"
...
globalvar_z
myClass
myMethod()
write(globalvar_a)
cli()
globalbase = "otherpath/"
main()
cli()
So the paths need to be created in / after cli() which forces them out of the module scope and thus they are not available in myClass / myMethod. Making all of them global
would become ugly.
What are common programming / design patterns to handle this situation?
Aucun commentaire:
Enregistrer un commentaire