[issue27991] In the argparse howto there is a misleading sentence about store_true

2016-09-11 Thread Berker Peksag

Berker Peksag added the comment:

Good catch, thanks!

--
nosy: +berker.peksag
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27991] In the argparse howto there is a misleading sentence about store_true

2016-09-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0e45cd7859ec by Berker Peksag in branch '3.5':
Issue #27991: Remove incorrect sentence about store_true
https://hg.python.org/cpython/rev/0e45cd7859ec

New changeset 9a75fa28bd0a by Berker Peksag in branch 'default':
Issue #27991: Merge from 3.5
https://hg.python.org/cpython/rev/9a75fa28bd0a

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27991] In the argparse howto there is a misleading sentence about store_true

2016-09-06 Thread py.user

New submission from py.user:

https://docs.python.org/3/howto/argparse.html#combining-positional-and-optional-arguments
"And, just like the “store_true” action, if you don’t specify the -v flag, that 
flag is considered to have None value."

This sentence is misleading. It supposes that "store_true" action can save None 
value. But "store_true" action always saves True or False value.

An example:

This code was taken from the argparse howto. I've just added the -f option and 
printed args to the stdout.

a.py

#!/usr/bin/env python3

import argparse

parser = argparse.ArgumentParser()
parser.add_argument("square", type=int,
help="display the square of a given number")
parser.add_argument("-v", "--verbosity", action="count",
help="increase output verbosity")
parser.add_argument("-f", "--flag", action="store_true")
args = parser.parse_args()

print('args:', args)


The output in the console:

[guest@localhost bugs]$ ./a.py 1
args: Namespace(flag=False, square=1, verbosity=None)
[guest@localhost bugs]$ 


In the output we see that the -f option have got the False value not None.

Applied a patch to the issue that just removes words about analogy with 
store_true action.

--
assignee: docs@python
components: Documentation, Library (Lib)
files: argparse_store_true.diff
keywords: patch
messages: 274725
nosy: docs@python, py.user
priority: normal
severity: normal
status: open
title: In the argparse howto there is a misleading sentence about store_true
type: behavior
versions: Python 3.6
Added file: http://bugs.python.org/file44419/argparse_store_true.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com