Change by paul j3 :
--
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue34479>
___
___
Python-bugs-list
paul j3 added the comment:
In your proposed change:
params = dict(vars(action), prog=self._prog)
+ if action.option_strings:
+ params['flag'] = action.option_strings[0]
'params', as I noted earlier already includes the 'dest
paul j3 added the comment:
I'm closing this since the https://bugs.python.org/issue11874 fix also handles
this issue.
--
resolution: -> fixed
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.pyth
Change by paul j3 :
--
resolution: -> not a bug
___
Python tracker
<https://bugs.python.org/issue34479>
___
___
Python-bugs-list mailing list
Unsubscrib
Change by paul j3 :
--
resolution: -> not a bug
___
Python tracker
<https://bugs.python.org/issue34458>
___
___
Python-bugs-list mailing list
Unsubscrib
Change by paul j3 :
--
resolution: -> rejected
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by paul j3 :
--
resolution: -> rejected
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue34188>
___
Change by paul j3 :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue34046>
___
paul j3 added the comment:
If I add an argument to the mutexGroup as suggested by xiang
In [7]: mutexGroup.add_argument('--foo', action='store_true')
Out[7]: _StoreTrueAction(option_strings=['--foo'], dest='foo', nargs=0,
const=True, default=False, typ
paul j3 added the comment:
This is duplicate of https://bugs.python.org/issue26952 - argparse help
formatter crashes
The same issue - a mutually exclusive group without arguments.
It also deals with issue of nesting groups.
--
resolution: -> duplicate
stage: -> resolved
paul j3 added the comment:
https://bugs.python.org/issue29553 deals with a similar problem, the usage
display when one mutually exclusive group is embedded in another mutually
exclusive group. In that case, usage is displayed, but with some missing
brackets.
As here there are two issues
Change by Paul Moore :
--
nosy: -paul.moore
___
Python tracker
<https://bugs.python.org/issue34694>
___
___
Python-bugs-list mailing list
Unsubscribe:
Paul Moore added the comment:
I don't think this is expected behaviour. It's not documented what should
happen in this case but the behaviour suggested by the OP (to search for the
path as given, followed by [path+e for e in
os.environ['PATHEXT'].split(os.pathsep)] se
Paul Moore added the comment:
On further reflection, I'm less sure that the proposed behaviour is the best
option, but I do think this warrants further consideration.
--
___
Python tracker
<https://bugs.python.org/is
paul j3 added the comment:
The preferred way of adding new features to the Formatter is to subclass it,
and modify one or more methods. That's what the existing alternative
formatters do.
A user can easily create such a subclass, and use it with their own parser,
without having to m
paul j3 added the comment:
The `type` parameter is normally a function (or more generally a callable).
When given a string it should convert it as needed, or raise an error. In your
example that function is the stock, 'int()'.
Test `int('123')`, `int('1e3')
Change by paul j3 :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue34803>
___
paul j3 added the comment:
An alternative to customizing a HelpFormatter is to write your own utility
`add_argument` function, e.g.
def my_add_argument(parser, *args, add_default=True, **kwargs):
if add_default:
help = kwargs.get('help','')
help +=
paul j3 added the comment:
As documented in
https://docs.python.org/3/library/argparse.html#the-namespace-object
you can create your own 'namespace' class, that does everything you want and
more. argparse makes very few assumptions about the object - using getattr,
setattr, a
Change by paul j3 :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue32756>
___
paul j3 added the comment:
I'm going to close this issue. The current behavior is a logical consequence
of how option_strings and abbreviations are handled. Handling this particular
case differently would be require adding a special test, as opposed to a minor
tweak to the current
paul j3 added the comment:
https://bugs.python.org/issue28742
argparse.ArgumentDefaultsHelpFormatter sometimes provides inaccurate
documentation of defaults, so they should be overrideable
is asking for something similar - the ability to override the automatic
`%(default)s` in certain cases
paul j3 added the comment:
https://bugs.python.org/issue13280, argparse should use the new Formatter class
Raymond Hettinger argued against making such a switch.
However there may be some value in allowing its use in parallel with the '%'
style of formatting. That is, if the
paul j3 added the comment:
Thinking about https://bugs.python.org/issue34744, I realized that the new
style formatting could provide some added flexibility to the help lines.
I think new style formatting could be added in parallel with the existing
style, as an alternative, not as a
New submission from Paul Bailey :
http.cookiejar.DefaultCookiePolicy should support the secure websocket protocol
wss. WebSockets start off as HTTP requests and then get upgraded but have a
different protocol of `wss` instead of `https`. This means secure cookies are
not passed through by
Paul Hoffman added the comment:
Bumping this thread a bit. It appears that this "internal" function is being
talked about out in the real world. I came across it in a recent blog post, saw
that it wasn't in the official documentation, and went looking here.
I propose that i
Change by Paul Ganssle :
--
nosy: +p-ganssle
___
Python tracker
<https://bugs.python.org/issue34903>
___
___
Python-bugs-list mailing list
Unsubscribe:
paul j3 added the comment:
The results of reading one of these @-prefix files are just spliced into the
`argv` list before it is parsed. This is done early in the parsing method, in
the
_read_args_from_files
method. The documentation illustrates how this file reading can be modified to
paul j3 added the comment:
If I define a 'type' function like:
def readdata(astr):
if astr.startswith('@'):
with open(astr[1:], 'r') as f:
d = json.load(f)
return d
else:
return astr
I can use it to load a json fi
paul j3 added the comment:
I'm going to close this.
Python makes it easy to test for Exception class. Testing exception messages
is messy, especially if the test wants to compare the message against 'generic
message'.
I don't see anything generic about the messages pr
paul j3 added the comment:
A related closed request: https://bugs.python.org/issue30220
that wants to test ValueError for non-generic message, instead of using
ArgumentTypeError.
--
___
Python tracker
<https://bugs.python.org/issue20
paul j3 added the comment:
Adding a new 'type' function or factor is certainly possible, and probably will
be free of backward compatibility issues. But so far no other custom type has
been added to argparse.
https://bugs.python.org/issue23884 - rejects adding a DateTime cl
paul j3 added the comment:
This kind of file read can be done just as easily after parsing. For example
using the function in my previous post:
In [127]: parser = argparse.ArgumentParser()
In [128]: parser.add_argument('-d','--data');
In [129]: args = parser.parse_a
Change by Paul Ganssle :
--
nosy: +p-ganssle
___
Python tracker
<https://bugs.python.org/issue35004>
___
___
Python-bugs-list mailing list
Unsubscribe:
paul j3 added the comment:
I think it's the same issue. A dash argument that is not clearly a number is
interpreted as an optional's flag. With few exceptions, the parser does not
examine the contents of the string
It tests the initial character, it tests for space, it tests f
Change by paul j3 :
--
resolution: -> duplicate
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue35049>
___
New submission from Paul Crowley :
random.sample currently uses either a Fisher-Yates shuffle, or rejection
sampling, to achieve sampling without replacement. I propose using reservoir
sampling or "cardchoose"; these are similar performance or sometimes faster,
and don't n
Change by Paul Crowley :
--
keywords: +patch
pull_requests: +9510
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue35094>
___
___
Py
Paul Crowley added the comment:
I would be very grateful for your help finding those dicussions! I've tried
this search:
https://www.google.com/search?q=python+%22Reservoir+sampling%22+rhettinger
and found this discussion:
https://mail.python.org/pipermail/python-ideas/2016-April/0
Paul Crowley added the comment:
Thank you for a very comprehensive and helpful answer!
Yep, reservoir sampling makes n calls not k calls, and so should only be used
when k is a large fraction of n; in my patch it's k/n >= 1/2.
Because modern CPRNGs are so fast, I had been assum
Change by Paul Ganssle :
--
nosy: +p-ganssle
___
Python tracker
<https://bugs.python.org/issue19376>
___
___
Python-bugs-list mailing list
Unsubscribe:
Paul Ganssle added the comment:
@Victor: You mean a PR to fix the *issue* or a PR to add this to the docs?
The current behavior is pretty counter-intuitive, particularly because it also
fails because of the (relatively) little-known fact that 1900 happens to not be
a leap year because it is
Change by Paul Ganssle :
--
nosy: +p-ganssle
___
Python tracker
<https://bugs.python.org/issue35066>
___
___
Python-bugs-list mailing list
Unsubscribe:
Paul Ganssle added the comment:
According to the sqlite documentation, there's no fundamental datetime type in
sqlite: https://www.sqlite.org/datatype3.html#date_and_time_datatype
SQLite does not have a storage class set aside for storing dates
and/or times. Instead, the bui
Paul Ganssle added the comment:
With regards to automatically deducing column types, I am -1 on that. It has
way too many dangerous edge cases, and I know of countless bugs in software
that are the direct result of stringly-typed data being coerced into a specific
data type based on its
Change by Paul Ganssle :
--
nosy: +p-ganssle
___
Python tracker
<https://bugs.python.org/issue35171>
___
___
Python-bugs-list mailing list
Unsubscribe:
New submission from Paul Ganssle :
It seems that in issue #1322, `platform.dist` was deprecated, and is slated for
removal in Python 3.8, but it is currently used in
distutils.command.upload.upload_file:
https://github.com/python/cpython/blob/6843ffe4533e9f2cde036296fd932fef6f059687/Lib
Change by Paul Ganssle :
--
keywords: +patch
pull_requests: +9694
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue35186>
___
___
Py
Change by Paul Ganssle :
--
pull_requests: +9696
___
Python tracker
<https://bugs.python.org/issue35081>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Paul Ganssle :
--
nosy: +p-ganssle
___
Python tracker
<https://bugs.python.org/issue35190>
___
___
Python-bugs-list mailing list
Unsubscribe:
paul j3 added the comment:
This is a refinement of the patch with Message188609.
In parse_known_intermixed_args, the temporary capture of formatted usage has
been put in a try/finally structure.
Positionals are now 'deactivated' with
action.nargs = SUPPRESS
action.default
Paul Moore added the comment:
There's also https://pypi.python.org/pypi/sarge
One other thing I *often* want to do when scripting commands is to capture
output, but provide some form of "progress" reporting (something like a dot per
line of output, usually). That's ann
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue9625>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.pyth
paul j3 added the comment:
I've added 2 more tests,
one with default='c', which worked before.
one with default=['a','b'], which only works with this change.
http://bugs.python.org/issue16878 is useful reference, since it documents
the differences between
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue16468>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.pyth
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue16418>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.pyth
paul j3 added the comment:
chris.jerdonek wrote:
"Also, to answer a previous question, the three places in which the choices
string is used are: in the usage string (separator=','), in the help string
when expanding "%(choices)s" (separator=', '), and in
paul j3 added the comment:
The exit and error methods are mentioned in the 3.4 documentation, but there
are no examples of modifying them.
16.4.5.9. Exiting methods
ArgumentParser.exit(status=0, message=None)
ArgumentParser.error(message)
test_argparse.py has a subclass that
New submission from paul j3:
As discussed in issue 16468, a metavar may be used to provide an alternative
representation of a choices option. However if a metvar like 'range(20)' is
used, usage formatter strips off the '()'.
>>> parser.add_argument('foo&
Changes by paul j3 :
--
components: +Library (Lib)
type: -> behavior
versions: +Python 3.4
___
Python tracker
<http://bugs.python.org/issue18349>
___
___
Py
paul j3 added the comment:
There still is one "choices='XYZ'" example (16.4.5.1. Sub-commands) but the
focus isn't on choices.
--
nosy: +paul.j3
___
Python tracker
<http:
paul j3 added the comment:
test_argparse.py has some "choices='abc'" cases.
In those should "parser.parse_args(['--foo','bc'])" be considered a success or
failure?
The underlying issue here is that while string iteration behaves l
paul j3 added the comment:
Change "choices='abc'" to "choices=['a', 'b', 'c']", as discussed in issue
16977 (use of string choices is a bad example)
--
Added file: http://bugs.python.org/file30762/issue9625_2.patch
_
paul j3 added the comment:
I'd suggest not worrying about the default metavar in the _expand_help()
method. The formatted choice string created in that method is only used if the
help line includes a '%(choices)s' string. The programmer can easily omit that
if he isn
paul j3 added the comment:
Changing _check_value from:
def _check_value(self, action, value):
# converted value must be one of the choices (if specified)
if action.choices is not None and value not in action.choices:
...
to
def _check_value(self, action
paul j3 added the comment:
This patch generally deals with the choices option, and specifically the
problems with formatting long lists, or objects that have __contains__
but not __iter__. But it also incorporates issues 9849 (better add_argument
testing) and 9625 (choices with *). It may be
paul j3 added the comment:
I just posted a patch to http://bugs.python.org/issue16468 that deals with this
'bc' in 'abc' issue.
--
___
Python tracker
<http://bug
paul j3 added the comment:
I just posted a patch to http://bugs.python.org/issue16468 that uses (and
tests) this fix.
--
___
Python tracker
<http://bugs.python.org/issue18
paul j3 added the comment:
The patch I just posted to http://bugs.python.org/issue16468 uses this fix.
--
___
Python tracker
<http://bugs.python.org/issue9
paul j3 added the comment:
In the patch I just posted to http://bugs.python.org/issue16468 I address this
long list issue in several ways:
In the Usage line, the metavar gives the user an alternative
In the expanded help line the user can just omit the '%(choices)s'
In _check_
paul j3 added the comment:
I included this patch (with minor changes) in a patch that I just posted to
http://bugs.python.org/issue16468. That issue deals with the argument choices
option, which can be tested along with nargs and metavars
paul j3 added the comment:
This approach of simply adding the existing actions to the group's
_group_actions works fine, at least when it comes catching the error.
It may be difficult to get a useful usage line. In usage, arguments appear in
the order in which they were created, opti
paul j3 added the comment:
One usage option is to make a subclass of HelpFormatter (the accepted way of
customizing a formatter), and write a function that formats each group
independently. For the example case, the resulting format might be:
usage: PROG [-h] [-b] [-a | -c] [-a | -d]
-h
paul j3 added the comment:
While playing with some examples, I found that exclusive group formatting has
another failure case. If the usage line is long enough to wrap, optionals and
positionals are formatted separately, with positionals appearing on a separate
line(s). That means that if a
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue11874>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.pyth
paul j3 added the comment:
If the arg_parts are passed through the same cleanup as the 'text' (and empty
strings removed), then
text = ' '.join(arg_parts)
In that case there would be no need to return both (text, arg_parts).
Parenthesis in the metavar could als
paul j3 added the comment:
This patch adds a MultiGroupHelpFormatter that formats groups even if they
share actions or the actions are not in the same order as in the parse._actions
list. It sorts the groups so positional actions, if any appear in the correct
order.
A long test case
paul j3 added the comment:
I just filed a patch with http://bugs.python.org/issue10984 (argparse
add_mutually_exclusive_group should accept existing arguments to register
conflicts) that includes the latest patch from this issue. I tweaked it so
_format_actions_usage only returns arg_parts
paul j3 added the comment:
This issue should also preserve a metavar like: '(one)two', i.e. '(' at the
start.
In http://bugs.python.org/issue10984 these _re replacements are applied to
individual action strings as well as the whole usage line. So if () are to be
re
paul j3 added the comment:
This patch produces the same usage as before, but I have rewritten
_format_actions_usage() for both HelpFormatter and MultiGroupFormater.
The original HelpFormatter._format_actions_usage() formats the actions, splices
in group markings, cleans up the text, if needed
paul j3 added the comment:
Here's a patch that takes a different approach - rewrite
_format_actions_usage() so it formats groups (and unattached actions) directly.
It uses the same logic to determine when to format a group, but then it calls
_format_group_usage() to format the
paul j3 added the comment:
I just submitted at patch to http://bugs.python.org/issue11874 that takes care
of this issue as well.
I rewrote _format_actions_usage() so it formats the parts directly, so there is
no need cleanup or parse the full text string
paul j3 added the comment:
I just submitted a patch to http://bugs.python.org/issue11874 which rewrites
_format_actions_usage(). It now formats the groups and actions directly,
keeping a list of these parts. It no longer has to cleanup or split a usage
line into parts. So it is not
paul j3 added the comment:
I just submitted a patch to http://bugs.python.org/issue11874 that
substantially rewrites _format_actions_usage(). It generates the group and
action parts separately, and does not do the kind of cleanup that produces this
issue
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue18467>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.pyth
paul j3 added the comment:
I think this example illustrates your issue:
class FooAction(argparse.Action):
def __call__(self, parser, namespace, values,
option_string = None):
if values=='Q':
setattr(namespace,
New submission from Paul Moore:
Some small improvements to the powershell "Activate" script for venvs:
1. Can be run as a command, rather than needing to be dot sourced. This matches
the behaviour of bat files, and of virtualenv's "activate" script, and avoids a
New submission from Paul Moore:
Adds "exe wrapper" functionality to the Windows launcher. This is a preliminary
patch, for comments - the code is there and works, but I need to add
documentation (and maybe tests - are there any existing tests for the launcher?)
Also to be consider
Changes by Paul Moore :
--
keywords: +patch
Added file: http://bugs.python.org/file30966/launcher_wrapper.patch
___
Python tracker
<http://bugs.python.org/issue18
Changes by Paul Moore :
--
nosy: +tim.golden
___
Python tracker
<http://bugs.python.org/issue18491>
___
___
Python-bugs-list mailing list
Unsubscribe:
Paul Moore added the comment:
Correct about .pyw files - I had forgotten those, I will update the patch.
The idea of "support code" was to (somewhat) alleviate Mark's question about
"what is this for", I was wondering if it was worth adding a module to the
stdlib whic
Paul Moore added the comment:
I've no problem with that suggestion. The patch is clean enough that ifdef-ing
it out won't be hard.
Revised patch incoming :-) It's needed for the pyw support in any case.
--
___
Python
paul j3 added the comment:
Since parse_args takes an optional Namespace argument, you can set the its
initial value to almost anything. For example, with the functions defined
previously:
parser = argparse.ArgumentParser()
parser.add_argument('-a','--algorithm
Paul Moore added the comment:
Updated patch, as per discussion.
--
Added file: http://bugs.python.org/file30994/launcher_wrapper.patch
___
Python tracker
<http://bugs.python.org/issue18
Changes by Paul Moore :
Removed file: http://bugs.python.org/file30966/launcher_wrapper.patch
___
Python tracker
<http://bugs.python.org/issue18491>
___
___
Python-bug
Changes by paul j3 :
--
nosy: +paul.j3
___
Python tracker
<http://bugs.python.org/issue14074>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.pyth
paul j3 added the comment:
My rewrite of _format_actions_usage in http://bugs.python.org/issue11874 should
take care of this issue. It keeps the groups and actions separate until the
final formatting step, bypassing the regular expression parsing.
--
nosy: +paul.j3
paul j3 added the comment:
This patch fixes the problem by joining the metavar terms with '|'. So the
help for the test case (adapted from an existing tuple test) looks like:
usage: PROG [-h] W1 [W2 ...] [X1 [X2 ...]] Y1 Y2 Y3 [Z1]
positional arguments:
W1|W2 w
New submission from Paul Moore:
Make the Windows Python installer set PATHEXT when "Register Python extensions"
is set. This allows users to run a scripy by typing the name of the .py file at
the command line without the .py extension.
The patch needs review - I have not been abl
paul j3 added the comment:
"msg113512 - (view) Author: Steven Bethard (bethard)
Seems like there's minimally the bug that argparse should currently throw an
error if you add an argument after subparsers (since that argument will never
be parsed under the current semantics).&qu
1701 - 1800 of 3028 matches
Mail list logo