[Python] Best way to get all environment variables starting with specific prefix in python

Discussão em 'Python' iniciado por Stack, Março 31, 2025.

  1. Stack

    Stack Membro Participativo

    I want to get all the environment variables starting with a specific prefix and save them (without prefix) into a dictionary. Is there any better way than getting all the os.environ variables and searching through them? I also need those to be merged with a config file, so if you know any library in python which is like Viper in go (which handles both environment variables and config files and merging of them with priority), it will be a huge help.

    UPDATE:

    my configs are not simple app config, they are users config with some structures in it, so it's not a simple key value pair. It also might be in different formats, such as YAML, INI, JSON, etc.

    Continue reading...

Compartilhe esta Página