[issue15613] argparse ArgumentDefaultsHelpFormatter interacts badly with --arg and nargs=+

2012-08-09 Thread Alex Jurkiewicz

New submission from Alex Jurkiewicz:

Sample code:

#!/usr/bin/env python
import argparse

print("\n\narg=foo, nargs=+")
parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('foo', nargs='+', help='foos', default=['foo1', 'foo2'])
parser.print_help()

print("\n\narg=foo, nargs=*")
parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('foo', nargs='*', help='foos', default=['foo1', 'foo2'])
parser.print_help()

print("\n\narg=--foo, nargs=+")
parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--foo', nargs='+', help='foos', default=['foo1', 'foo2'])
parser.print_help()

print("\n\narg=--foo, nargs=*")
parser = 
argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--foo', nargs='*', help='foos', default=['foo1', 'foo2'])
parser.print_help()


The first example's help text for 'foo' is missing "(default: ['foo1', 
'foo2'])". I tested 2.7.2, 2.7.3, 3.2.3.

--
components: Library (Lib)
messages: 167854
nosy: Alex.Jurkiewicz
priority: normal
severity: normal
status: open
title: argparse ArgumentDefaultsHelpFormatter interacts badly with --arg and 
nargs=+
type: behavior
versions: Python 2.7, Python 3.2

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



[issue29002] typing.AnyStr doc is unclear about python2 unicode support

2016-12-17 Thread Alex Jurkiewicz

New submission from Alex Jurkiewicz:

The typing.AnyStr documentation:

https://docs.python.org/3/library/typing.html#typing.AnyStr

It gives some examples using u-strings (u'foo') but doesn't make explicit some 
subtleties about behaviour with Python 2. Specifically, with Python 2 all the 
given examples work, and even this works:

concat("foo", u"bar")

Which seems contrary to the goal of AnyStr being "used for functions that may 
accept any kind of string without allowing different kinds of strings to mix".

I think the documentation should call out that for Python 2, AnyStr doesn't 
distinguish between str & unicode, and mention that in python 2, b'str' is 
equivalent to 'str' (I know this is mentioned elsewhere, but it seems useful to 
repeat it here).

--
assignee: docs@python
components: Documentation
messages: 283524
nosy: aj, docs@python
priority: normal
severity: normal
status: open
title: typing.AnyStr doc is unclear about python2 unicode support
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

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



[issue28112] Add callback to functools.lru_cache

2016-09-12 Thread Alex Jurkiewicz

New submission from Alex Jurkiewicz:

I'd like to add support for functools.lru_cache to have a callback parameter 
that runs every time an item is evicted from the cache. I've written a small 
prototype here:

https://github.com/alexjurkiewicz/cpython/commit/2f788387466720d47f2c82242ac33b107b0bf470

The prototype is incomplete:
* No C implementation
* Doesn't run on lru_cache.cache_clear()
* It would be nice to pass through args/kwargs for each evicted item

Comments welcome!

--
components: Library (Lib)
messages: 276171
nosy: aj
priority: normal
severity: normal
status: open
title: Add callback to functools.lru_cache
type: enhancement
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

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



[issue28112] Add callback to functools.lru_cache

2016-09-12 Thread Alex Jurkiewicz

Alex Jurkiewicz added the comment:

OK, thanks for the feedback. For future searchers I am using the pylru module 
instead:
https://pypi.python.org/pypi/pylru

--

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