0

I have a configuration file in Python. It was suggested to me to use classes. So I have a lot of constants like this:

class Paths:
    class Sources:
        strategylab = 'src/strategylab/'

    class Projects:
        home = 'prj/'

        os.makedirs(home, exist_ok=True)

        scenarios_outputs = 'outputs/'
        scenarios = 'scenarios/'
        datasets = 'datasets/'

        # to be configured dynamically
        project_path = None
        project_single_scenario_path = None
        project_single_scenario_output_path = None
        project_outputs_path = None
        project_name = None
        project_datasets_path = None

    class Workspace:
        temp = 'temp/'
        ftp = 'ftp/'

        # to be configured dynamically
        home = None
        temp_location = None
        ftp_location = None

    class Template:
        home = 'model/'

        # to be configured dynamically
        single_project_template_location = None

What advantages should I have if I transform them in ENUM? Can I still add values dynamically?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Lore
  • 1,286
  • 1
  • 22
  • 57

1 Answers1

1

Enums are for constants -- paths on a harddrive don't feel very constant:

  • they could change between program releases
  • they could change due to user preferences

Enum's are not designed to have values added once they have been created.

Ethan Furman
  • 63,992
  • 20
  • 159
  • 237