python - tornado中使用parse_command_line(final=False) 沒能理解final是做什么的
問題描述
大概知道parse_command_line是用來解析命令行的,但是不理解里面的final參數是作什么的。順便咨詢一下學習tonardo的學習資源(知道官方文檔是最好的)和書籍
問題解答
回答1:通過這樣,找到源代碼,請自己看方法文檔
If final is False, parse callbacks will not be run.
This is useful for applications that wish to combine configurationsfrom multiple sources.
def parse_command_line(self, args=None, final=True):'''Parses all options given on the command line (defaults to`sys.argv`).Note that ``args[0]`` is ignored since it is the program namein `sys.argv`.We return a list of all arguments that are not parsed as options.If ``final`` is ``False``, parse callbacks will not be run.This is useful for applications that wish to combine configurationsfrom multiple sources.'''if args is None: args = sys.argvremaining = []for i in range(1, len(args)): # All things after the last option are command line arguments if not args[i].startswith('-'):remaining = args[i:]break if args[i] == '--':remaining = args[i + 1:]break arg = args[i].lstrip('-') name, equals, value = arg.partition('=') name = self._normalize_name(name) if name not in self._options:self.print_help()raise Error(’Unrecognized command line option: %r’ % name) option = self._options[name] if not equals:if option.type == bool: value = 'true'else: raise Error(’Option %r requires a value’ % name) option.parse(value)if final: self.run_parse_callbacks()return remaining
相關文章:
1. macos - mac下docker如何設置代理2. angular.js - ng-grid 和tabset一起用時,grid width默認特別小3. apache - 本地搭建wordpress權限問題4. 熱切期待朱老師的回復,網頁視頻在線播放器插件配置錯誤5. docker 下面創建的IMAGE 他們的 ID 一樣?這個是怎么回事????6. java - Spring Mvc全局異常處理器@ControllerAdvice不起作用?7. Whitelabel錯誤頁面發生意外錯誤(類型=未找到,狀態= 404)/WEB-INF/views/home.jsp8. javascript - web網頁版app返回上一頁按鈕在ios設備失效怎么辦?安卓上可以,代碼如下,請大神幫助,萬分感謝。9. Android下,rxJava+retrofit 并發上傳文件和串行上傳文件的效率為什么差不多?10. css3 - transition屬性當鼠標一開的時候設置的時間不起作用
