一个简单的轻量级类,允许用户回退默认值

dfault的Python项目详细描述


一个简单的轻量级类,允许用户在默认情况下回退 值

安装

pip3 install --user dfault

用法

基本示例

fromdfault.objectsimportDfaultexpected_values={"search_engine":"duckduckgo","website":"http://www.duckduckgo.com"}d=Dfault(expected_values)d.get("search_engine","google")# returns "duckduckgo" as the value existsd.get("favourite_team","leafs")# returns "leafs" as there are no values for "favourite_team"

配置

importconfigparserfromdfault.objectsimportDfaultconfig=configparser.ConfigParser()# .config:# [USER]# team=leafs#config.read(".config")default_config=config["user"]d=Dfault(default_config)d.get("team","raptors")# returns "leafs" as the value exiss in the configd.get("username","joeyism")# returns "joeyism" as there is no "username" value in the config file

版本

  • 1.0.x
    • 错误修复
  • 1.0.0
    • 首次发布

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何使用java在linux上编写系统日志   如何在同一个现有变量上多次更改变量的值?(爪哇)   易失性字符串Java   java需要帮助通过PreparedStatement编写适当的搜索查询   JavaMaven项目是否获得其他Maven项目的版本?   java如何在Eclipse中使用Drool应用程序抑制信息和警告调试信息   Java中FileReader和FileInputStream的区别是什么?   java如何为此编写HQL查询?   java方法根本不返回任何内容   VLCJ通过单个java程序控制多个音频文件   java为什么这个println命令不开始一个新行?   java如何创建自己的文件扩展名。odt或。医生?   声明字符串后,java在条件语句中设置int值   通过k8s作业文件将cmd参数传递给docker容器中的java应用程序