ConfigParser vs. import config

前端 未结 4 958
北荒
北荒 2021-02-05 01:42

ConfigParser is the much debated vanilla configuration parser for Python.
However you can simply import config where config.py has python code whic

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 02:06

    The biggest issue I see with import config is that you don't know what will happen when you import it. Yes, you will get a set of symbols that are naturally referenced using a . style interface. But the code in the configuration file can also do who-knows-what. Now, if you completely trust your users, then allowing them to do whatever they feel like in the config file is possibly a good thing. However, if you have unknown quantities, or you want to protect users from themselves, then having a configuration file in a more traditional format will be safer and more secure.

提交回复
热议问题