[issue27497] csv module: Add return value to DictWriter.writeheader

2019-05-06 Thread MICHAEL BLAHAY


MICHAEL BLAHAY  added the comment:

I would like to drive this to conclusion since it appears this issue has not 
had any real activity in a while. First thing that needs to be determined is 
whether this enhancement is still desirable. Who can answer this?

--
nosy: +MICHAEL BLAHAY

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



[issue27497] csv module: Add return value to DictWriter.writeheader

2019-05-06 Thread MICHAEL BLAHAY


MICHAEL BLAHAY  added the comment:

Ah ha, so there is. I'm glad this one will get closed out. Sorry for noob 
mistake.

--

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



[issue11698] Improve repr for structseq objects to show named, but unindexed fields

2019-05-06 Thread MICHAEL BLAHAY


MICHAEL BLAHAY  added the comment:

I will work on this

--
nosy: +MICHAEL BLAHAY

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



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread MICHAEL BLAHAY


MICHAEL BLAHAY  added the comment:

I will pick this on up

--
nosy: +MICHAEL BLAHAY

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



[issue36582] collections.UserString encode method returns a string

2019-05-06 Thread MICHAEL BLAHAY


MICHAEL BLAHAY  added the comment:

My mistake, dfortunov is already working on this one.

--

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



[issue11698] Improve repr for structseq objects to show named, but unindexed fields

2019-05-06 Thread MICHAEL BLAHAY


MICHAEL BLAHAY  added the comment:

I have been advised to avoid enhancements like this one, so I am setting this 
back down. Also, this should be relabeled as easy(c).

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-06 Thread Michael Blahay


Michael Blahay  added the comment:

Here is a test that more explicitly shows the problem. 

>>> from collections import UserList
>>> UserList([0,1,2,3,4,5])[0:2].__class__

>>> 

It can clearly be seen here that the return type of the slicing operator is 
list when it should, in this case, be UserList (or whatever class one is using 
that is derived from UserList).

--
nosy: +mblahay

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-06 Thread Michael Blahay


Michael Blahay  added the comment:

The root cause of this issue seems to be the failure to implement type usage in 
__getitem__ when the deprecated __getslice__ was removed. This is why slicing 
worked correctly in 2.7, but not the 3.x versions.

In 3.8, the __getitem__ method is used to create the slice, but here we can see 
that all it does is pass the task to data, which is of type list and then fails 
to convert the result to the correct type.

  def __getitem__(self, i): return self.data[i]

Using other methods as examples, the fix should look like this:

  def __getitem__(self, i): return self.__class__(self.data[i])

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-06 Thread Michael Blahay


Michael Blahay  added the comment:

It is also worth noting that the definition of UserList moved from 
Lib/UserList.py in 2.7 to Lib/collections/__init__.py in 3.x

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-06 Thread Michael Blahay


Michael Blahay  added the comment:

Results from a quick unit test on the proposed changes were positive:

>>> from collections import UserList
>>> UserList([0,1,2,3,4,5])[0:2].__class__


If you compare this result with the one a couple comments above, you can see 
that the result is no longer a list, but rather of type UserList.

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-07 Thread Michael Blahay


Michael Blahay  added the comment:

Thank you for bringing up that PR. My team will review and try to find out why 
it was closed without a merge.

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-07 Thread Michael Blahay


Michael Blahay  added the comment:

Please note that I am working with Erick Cervantes at PyCon2019 on this issue.

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-07 Thread Michael Blahay


Michael Blahay  added the comment:

Let it be known that the author of PR 4981 is known as vaultah. He/she 
personally closed the pull request this morning stating a lack of need to be 
recognized for the work. Per his/her instructions I am reviewing the changes 
and incorporating in our solution as needed. Thank you vaultah!

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-07 Thread Michael Blahay


Michael Blahay  added the comment:

Ryan, what are the exact steps to reproduce the problem? This is what I get 
when I run the code you included:

>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('things', nargs=argparse.REMAINDER, default=['nothing'])
_StoreAction(option_strings=[], dest='things', nargs='...', const=None, 
default=['nothing'], type=None, choices=None, help=None, metavar=None)
>>> parser.parse_args([])
Namespace(things=[])
>>> Namespace(things=[])
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'Namespace' is not defined

--
nosy: +mblahay

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-08 Thread Michael Blahay


Change by Michael Blahay :


--
pull_requests: +13114

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-08 Thread Michael Blahay


Michael Blahay  added the comment:

PR 13150, the recreation of PR 4981, was noticed just after I created PR 13169. 
It was decided to continue forward with PR 13169 since PR 13150 contained 
changes that were out of scope for BPO-27639 for which it was suspected might 
have been the cause of the non-merging of PR 4981. Thank for identifying 
Dmitry; I did my best to give credit where credit was due.

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-08 Thread Michael Blahay


Michael Blahay  added the comment:

Okay, so the expected output after running parse.parse_args([]) is 
Namespace(['nothing'])

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-08 Thread Michael Blahay


Michael Blahay  added the comment:

Ryan, I have reviewed the documentation at 
https://docs.python.org/3/library/argparse.html#nargs and must admit that there 
is not a definitive answer that I can see regarding the defined behavior should 
there be no command line arguments that are in fact remaining. One could 
certainly argue that the empty list is the expression of the fact that no 
remaining arguments could be found. One can also argue that when seeking the 
remaining arguments, a list that may be zero to many elements in size, that by 
definition there cannot be a default.

Can you cite any documentation that would support your claim?

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-09 Thread Michael Blahay


Michael Blahay  added the comment:

For those that are wondering what is going on with PR 13181 and PR 13203, those 
are both for back porting the change to 3.7. The auto generated PR 13181 failed 
for an unknown reason and then the bot deleted the branch so the PR could not 
be taken any further. PR 13203 is a manual attempt at the backport which is 
moving along much for successfully.

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-10 Thread Michael Blahay


Michael Blahay  added the comment:

For the purpose of facilitating continuing conversation, here are two tests 
that contrast the use of * versus REMAINDER

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('foo', nargs=1,default=['none'])
parser.add_argument('bar', nargs=argparse.REMAINDER,default=['nothing'])
parser.add_argument('baz', nargs='*', default=['nada'])
parser.parse_args('a b c'.split())

Out[7]: Namespace(bar=['b', 'c'], baz=['nada'], foo=['a'])

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('foo', nargs=1,default=['none'])
parser.add_argument('baz', nargs='*', default=['nada'])
parser.add_argument('bar', nargs=argparse.REMAINDER,default=['nothing'])
parser.parse_args('a b c'.split())

Out[8]: Namespace(bar=[], baz=['b', 'c'], foo=['a'])

You can see that * and REMAINDER do differ in functionality when they are the 
last defined argument.

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-10 Thread Michael Blahay


Michael Blahay  added the comment:

Here is another take on the issue, this time illustrated through the lens of 
optional arguments.

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--foo', nargs=1,default=['none'])
parser.add_argument('--baz', nargs='*', default=['nada'])
parser.add_argument('--bar', nargs=argparse.REMAINDER,default=['nothing'])
parser.parse_args('--foo a --bar b --baz c'.split())

Out[9]: Namespace(bar=['b', '--baz', 'c'], baz=['nada'], foo=['a'])

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--foo', nargs=1,default=['none'])
parser.add_argument('--baz', nargs='*', default=['nada'])
parser.add_argument('--bar', nargs=argparse.REMAINDER,default=['nothing'])
parser.parse_args('--foo a --baz b --bar c'.split())

Out[10]: Namespace(bar=['c'], baz=['b'], foo=['a'])

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--foo', nargs=1,default=['none'])
parser.add_argument('--baz', nargs='*', default=['nada'])
parser.add_argument('--bar', nargs=argparse.REMAINDER,default=['nothing'])
parser.parse_args([])

Out[11]: Namespace(bar=['nothing'], baz=['nada'], foo=['none'])

It is important to note that when an optional argument is not present then the 
default is always used, including for one using nargs=argparse.REMAINDER. In 
all three tests, bar is the argument using REMAIDER. In the first test, one can 
see that when bar isn't the last argument then anything else, including other 
arguments, are swept up as being arguments of bar. This greedy behavior for 
REMAINDER is something that * does not share (test 2).

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-10 Thread Michael Blahay


Michael Blahay  added the comment:

With the optional arguments, the determination about whether to use the default 
value is made based on whether the flag is present or not. When positional 
arguments are involved, the need for the defaults seems to in part be 
determined based on whether the argument exists. The fact that * and REMAINDER 
are zero-to-many in nature add some ambiguity into the situation. For the *, it 
seems that the positional argument only exists if there is at least one actual 
argument value that it can consume.

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('foo', nargs=1,default=['none'])
#parser.add_argument('bar', nargs=argparse.REMAINDER,default=['nothing'])
parser.add_argument('baz', nargs='*', default=['nada'])
parser.parse_args('a b'.split())

Out[25]: Namespace(baz=['b'], foo=['a'])

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('foo', nargs=1,default=['none'])
#parser.add_argument('bar', nargs=argparse.REMAINDER,default=['nothing'])
parser.add_argument('baz', nargs='*', default=['nada'])
parser.parse_args('a'.split())

Out[26]: Namespace(baz=['nada'], foo=['a'])

Mean while, the REMAINDER option makes the argument act as if it exists 
regardless of whether an actual argument value exists.

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('foo', nargs=1,default=['none'])
parser.add_argument('bar', nargs=argparse.REMAINDER,default=['nothing'])
#parser.add_argument('baz', nargs='*', default=['nada'])
parser.parse_args('a b'.split())

Out[27]: Namespace(bar=['b'], foo=['a'])

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('foo', nargs=1,default=['none'])
parser.add_argument('bar', nargs=argparse.REMAINDER,default=['nothing'])
#parser.add_argument('baz', nargs='*', default=['nada'])
parser.parse_args('a'.split())

Out[28]: Namespace(bar=[], foo=['a'])

To conclude, * and REMAINDER perform similar, but different, roles when used 
with positional arguments. With edge cases like the ones laid out above, it can 
be hard to conceptualize what the exact behavior should be. I will recommend 
that the documentation be updated to convey the following message: "When used 
with positional arguments, REMAINDER will never use the designated default 
value list. It will instead return an empty list if there are no values for the 
argument to consume. If the use of default values is desired, then * must be 
used."

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-10 Thread Michael Blahay


Michael Blahay  added the comment:

Much detail has been provided regarding why the default is ignored when user 
the REMAINDER option. The desire to add an exception has not. Is there anyone 
that can provide guidance on whether the combination of:
1. Positional Argument 
2. nargs=REMAINDER
3. default=something  
should raise an exception upon execution of the add_argument method?

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-10 Thread Michael Blahay


Michael Blahay  added the comment:

PR 13203 has finally made it through all checks successfully and is now 
awaiting merging. Please someone pick it up and merge it. Thank you

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-13 Thread Michael Blahay


Michael Blahay  added the comment:

Ryan, What say you? Will you be satisfied with the addition of a note in the 
documentation?

--

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



[issue32509] doctest syntax ambiguity between continuation line and ellipsis

2019-05-13 Thread Michael Blahay


Michael Blahay  added the comment:

At the end of msg309603 it was stated that this issue is being changed to an 
enhancement. Later on, Tim Peters changed it Type back to behavior, but didn't 
provide any detail about why. Should this issue still be considered an 
enhancement?

--
nosy: +mblahay

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-15 Thread Michael Blahay


Michael Blahay  added the comment:

PR 13203 is still waiting for merge

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-24 Thread Michael Blahay


Michael Blahay  added the comment:

PR 13203 is still waiting for merge

--

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



[issue27639] UserList.__getitem__ doesn't account for slices

2019-05-26 Thread Michael Blahay


Michael Blahay  added the comment:

Thank you Mark. Everything for this one is complete. The issue may be closed.

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-05-26 Thread Michael Blahay


Michael Blahay  added the comment:

Ryan, last chance, do you have any feedback?

--

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



[issue36913] Missing documentation for decorators

2019-05-26 Thread Michael Blahay


Michael Blahay  added the comment:

The PEP is not the first place I go looking for information on Python topics, 
just my two cents.

--
nosy: +mblahay

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



[issue17250] argparse: Issue 15906 patch; positional with nargs='*' and string default

2019-05-26 Thread Michael Blahay


Michael Blahay  added the comment:

Also see https://bugs.python.org/issue35495

--
nosy: +mblahay

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-06-17 Thread Michael Blahay


Michael Blahay  added the comment:

Need some help searching github to determine the blast radius of the proposed 
changes. How does one look for instances of argparse.REMAINDER that are used 
with a default value?

--

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



[issue35495] argparse does not honor default argument for nargs=argparse.REMAINDER argument

2019-07-18 Thread Michael Blahay


Michael Blahay  added the comment:

Ryan, I like option A as well, but it is a breaking change. Unlike in a 
compiled language where we could output a warning, making the proposed change 
could bring some software to a grinding halt. For now I'm going to make the 
documentation change and this issue can stay open for if there is a major 
version change that would allow such a breaking change.

--
versions: +Python 3.9 -Python 2.7, Python 3.6, Python 3.7, Python 3.8

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