zoukankan      html  css  js  c++  java
  • 一个经典的python字典生成式案例

     1 @lru_cache.lru_cache(maxsize=None)
     2 def get_commands():
     3     """
     4     Returns a dictionary mapping command names to their callback applications.
     5 
     6     This works by looking for a management.commands package in django.core, and
     7     in each installed application -- if a commands package exists, all commands
     8     in that package are registered.
     9 
    10     Core commands are always included. If a settings module has been
    11     specified, user-defined commands will also be included.
    12 
    13     The dictionary is in the format {command_name: app_name}. Key-value
    14     pairs from this dictionary can then be used in calls to
    15     load_command_class(app_name, command_name)
    16 
    17     If a specific version of a command must be loaded (e.g., with the
    18     startapp command), the instantiated module can be placed in the
    19     dictionary in place of the application name.
    20 
    21     The dictionary is cached on the first call and reused on subsequent
    22     calls.
    23     """
    24     commands = {name: 'django.core' for name in find_commands(upath(__path__[0]))}
    25 
    26     if not settings.configured:
    27         return commands
    28 
    29     for app_config in reversed(list(apps.get_app_configs())):
    30         path = os.path.join(app_config.path, 'management')
    31         commands.update({name: app_config.name for name in find_commands(path)})
    32 
    33     return commands
  • 相关阅读:
    Vue--会员管理列表页面,抽取BASE_URL
    Vue--系统权限拦截
    写译-冲刺班
    看到一篇有收获的博文【关于外挂生涯的忠告】(转载)
    笔记管理-vscode-印象笔记-git-博客园
    1.4条件和循环
    1.3撰写表达式
    1.2对象定义与初始化
    1.1如何写一个c++程序
    send()函数 recv()函数
  • 原文地址:https://www.cnblogs.com/Fmaj7/p/13175725.html
Copyright © 2011-2022 走看看