New submission from py.user: The example is:
def convert_arg_line_to_args(self, arg_line): for arg in arg_line.split(): if not arg.strip(): continue yield arg str.split() with default delimiters never returns empty or whitespace strings in the list. >>> ' x x '.split() ['x', 'x'] >>> ' '.split() [] >>> Therefore, the if condition doesn't ever continue the loop. It can be written: def convert_arg_line_to_args(self, arg_line): for arg in arg_line.split(): yield arg It's the same as: def convert_arg_line_to_args(self, arg_line): return iter(arg_line.split()) I guess, nothing uses next() for the result: def convert_arg_line_to_args(self, arg_line): return arg_line.split() Applied a patch with the last variant. ---------- assignee: docs@python components: Documentation, Library (Lib) files: args_ex_argline.diff keywords: patch messages: 235089 nosy: docs@python, py.user priority: normal severity: normal status: open title: In argparse docs simplify example about argline type: performance versions: Python 2.7, Python 3.4 Added file: http://bugs.python.org/file37934/args_ex_argline.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23356> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com