我想要一个.ini
引用特殊变量的条目,例如
[magic_module]
magic_directory: ${env:PWD}/magic
目前,我有非便携式
[magic_module]
magic_directory: C:/Users/user1/projects/project1/magic
I would like to have a .ini
path entry that is more portable instead of hard-coded to my computer. Does the Python ConfigParser
natively perform substitutions like this?
This is slightly different than SO question ConfigParser and String interpolation with env variable because I am wondering about any possible default interpolated variables, not just environment variables.
This is for passing information to a different module (mypy
) that uses ConfigParser
.
Specifically, this is for improving portability in a Python package. I'm trying to set the mypy_path
within a mypy.ini
while working with a pipenv-created virtualenv python environment. The user install module paths will change so I want to portably set that for mypy
.
使用 Python 3.7。