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

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出现编译错误,我不理解   java在gnu-trove库中是否有任何有序映射?   java Servlet应该有映射,但找不到Servlet   java时间和第二期显示1:10,而不是13:10   java Play Framework 1.2.7 Heroku更新崩溃   线程“main”java中的opencsv异常。lang.NoClassDefFoundError:org/apache/commons/lang3/ObjectUtils   selenium在java中隐藏警告消息   java使用ID引用将JSON实体反序列化为POJO   java无法在JRE 8中加载字体   一个线程中的异常/错误会使整个应用程序停止吗?   java访问重复子规则的元素标签;e、 g.用ANTLR解析(1,2,3)中的a   java如何从平移旋转中找到新坐标   使用HTML Java小程序托管jar文件存在安全问题   java如何按频率而不是字母顺序排列字符串数组   java清除bufferedReader和块以获得更多输入   java解密SAML2断言