Skip to content

Add configuration settings #8

Description

@mejroslav

You can add configuration settings to your code using configparser. This enables you to quickly change the datasources, algorithms etc without changing the code (say no more to huge commented code blocks).

Concept

  1. Create config.ini file that looks like this:
[general]
datafile=path/to/datafile
algorithm=rungekutta8
outuput=path/to/output

[logging]
level=debug
logfile=path/to/logfile
  1. The flow should be the following (not sure about fallbacks....)
import configparser

config = configparser.ConfigParser()
config.read("config.ini")

...

self.Algorithm = config.get("general", "algorithm", fallback="RungeKutta8")
self.LogFile = config.get("logging", "logfile", fallback=None)

...
if self.Algorithm == "RungeKutta8":
    ...

You can also add default settings and much more...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions