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. dockerfile - [docker build image失败- npm install]2. angular.js - angular内容过长展开收起效果3. javascript - c#如何向js传值4. java - mybatis怎么实现在数据库中有就修改,没有就添加5. java中关于直接插入排序遇到的问题。6. 我在centos容器里安装docker,也就是在容器里安装容器,报错了?7. node.js - nodejs和前端JavaScript 字符串处理结果不一样是什么原因?8. docker gitlab 如何git clone?9. nignx - docker内nginx 80端口被占用10. node.js - mongoDB使用$gte的问题
![dockerfile - [docker build image失败- npm install]](http://www.haobala.com/attached/image/news/202311/1028105a80.png)