Live data from Hacker News

Best Practices for Working with Configuration in Python Applications

tech.preferred.jp

11–20 of 69 posts

Re: Best Practices for Working with Configuration in Python Applications

#11
Quick list of Python libraries that help with application configuration:

- Python application configuration -> https://github.com/edaniszewski/bison

- Configuration with env variables for Python -> https://github.com/hynek/environ_config

- Configuration library for python projects -> https://github.com/willkg/everett

- Strict separation of config from code -> https://github.com/henriquebastos/python-decouple

This is from my personal notes. See also: https://github.com/vinta/awesome-python#configuration

Anything else that we've missed ?

Re: Best Practices for Working with Configuration in Python Applications

#12

Quick list of Python libraries that help with application configuration: - Python application configuration -> https://github.com/edaniszewski/bison - Configuration with env variables for Python -> https://github.com/hynek/environ_config - Configuration library for python projects -> https://github.com/willkg/everett - Strict separation of config from code -> https://github.com/henriquebastos/python-decouple This is…

The two big ones in machine learning at least are Google's Gin:

https://github.com/google/gin-config

and Facebook's Hydra:

https://hydra.cc/

Re: Best Practices for Working with Configuration in Python Applications

#13

Earlier quoted context omitted.

I agree that python datetime objects are problematic, but for the opposite reason. It is tzinfo that is the sneaky disaster, the plain datetimes are fine. Transparent timezone awareness always fail, unless you are 100% certain that a tzaware datetime object will remain uncoverted from the very top to the very bottom of the stack and all the way up again no matter who is reading and what they are doing. For longterm m…

> I agree that python datetime objects are problematic, but for the opposite reason. It is tzinfo that is the sneaky disaster, the plain datetimes are fine. Why naive datetimes should be fine? How are they fine? What do they represent? > For longterm minimization of pain, bugs and effort, you convert datetimes to UTC This COULD work if naive objects had an IMPLIED UTC in their contract - e.g. naive objects are declar…

> Why naive datetimes should be fine? How are they fine? What do they represent?

They represent the date/time wherever the user is (location-independent). If I want to take a pill every Monday and Thursday at 10am, I don't want to get a notification at 5am just because I moved from the UK to NY.

Re: Best Practices for Working with Configuration in Python Applications

#14

Quick list of Python libraries that help with application configuration: - Python application configuration -> https://github.com/edaniszewski/bison - Configuration with env variables for Python -> https://github.com/hynek/environ_config - Configuration library for python projects -> https://github.com/willkg/everett - Strict separation of config from code -> https://github.com/henriquebastos/python-decouple This is…

Marshmallow. You can use its schema validation for any dict/json, which makes it a nice fit for validating json config files (which mitigates some of the json concerns from the article). Just immediately move the json.reads through a schema validate, build some classes around it for different config files.

marshmallow.readthedocs.io/en/

Re: Best Practices for Working with Configuration in Python Applications

#15

Quick list of Python libraries that help with application configuration: - Python application configuration -> https://github.com/edaniszewski/bison - Configuration with env variables for Python -> https://github.com/hynek/environ_config - Configuration library for python projects -> https://github.com/willkg/everett - Strict separation of config from code -> https://github.com/henriquebastos/python-decouple This is…

Pydantic https://pydantic-docs.helpmanual.io/usage/settings/

Re: Best Practices for Working with Configuration in Python Applications

#16

Quick list of Python libraries that help with application configuration: - Python application configuration -> https://github.com/edaniszewski/bison - Configuration with env variables for Python -> https://github.com/hynek/environ_config - Configuration library for python projects -> https://github.com/willkg/everett - Strict separation of config from code -> https://github.com/henriquebastos/python-decouple This is…

Here's my tiny contribution to the field: https://github.com/berislavlopac/figga

Re: Best Practices for Working with Configuration in Python Applications

#17

Quick list of Python libraries that help with application configuration: - Python application configuration -> https://github.com/edaniszewski/bison - Configuration with env variables for Python -> https://github.com/hynek/environ_config - Configuration library for python projects -> https://github.com/willkg/everett - Strict separation of config from code -> https://github.com/henriquebastos/python-decouple This is…

Here's my tiny contribution to the field: https://github.com/berislavlopac/figga

And I also like the .env approach: https://github.com/theskumar/python-dotenv

Re: Best Practices for Working with Configuration in Python Applications

#18

Quick list of Python libraries that help with application configuration: - Python application configuration -> https://github.com/edaniszewski/bison - Configuration with env variables for Python -> https://github.com/hynek/environ_config - Configuration library for python projects -> https://github.com/willkg/everett - Strict separation of config from code -> https://github.com/henriquebastos/python-decouple This is…

https://github.com/crdoconnor/strictyaml - typesafe YAML parser (solves the issues mentioned in 2 and 1).

Re: Best Practices for Working with Configuration in Python Applications

#19
post #15

Quick list of Python libraries that help with application configuration: - Python application configuration -> https://github.com/edaniszewski/bison - Configuration with env variables for Python -> https://github.com/hynek/environ_config - Configuration library for python projects -> https://github.com/willkg/everett - Strict separation of config from code -> https://github.com/henriquebastos/python-decouple This is…

Pydantic https://pydantic-docs.helpmanual.io/usage/settings/

Yes. Fastapi also uses the same - https://fastapi.tiangolo.com/advanced/settings/#pydantic-set...

Re: Best Practices for Working with Configuration in Python Applications

#20
post #3

Earlier quoted context omitted.

What’s naive and dangerous about Python’s Datetime objects?

Your question implies that you don't know about the nuisances of the datetime library :-) (see https://docs.python.org/3/library/datetime.html it's the first paragraph!) Python datetime objects, by design, can be naive or timezone-aware. Timezone-aware datetime objects are OK; they identify a certain instant in time. Naive datetime objects are Python-only abstractions (AFAIK) that don't identify anything in the real…

>What does the library do? Throw an exception? Associate an arbitrary timezone (e.g. UTC)? Associate the local, current timezone?

Naive datetime is what datetime.utcnow() returns. UTC is essentially a "default" timezone. I've always thought it made most sense in a library to assume it's UTC.

Post reply on HN