简体   繁体   中英

what are ${} in config.ini

I've been reading code base develop by someone else. In one of the config_file.ini it contains

[key]
id = John
pwd = 123123
server = ${common:prefix}server_name

What exactly is ${} doing? Also if there is reference that talks about it please let me know.

It's documented under configparser.ExtendedInterpolation . It's a syntax( ${section:option} ) to denote a value from a foreign section. For example, in the following config file the path option also refers to the system_dir value from Common section.

[Common]
home_dir: /Users
library_dir: /Library
system_dir: /System
macports_dir: /opt/local
    
[Frameworks]
Python: 3.2
path: ${Common:system_dir}/Library/Frameworks/
      ^^^^^^^^^^^^^^^^^^^^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM