[issue13299] namedtuple row factory for sqlite3

2012-08-21 Thread Russell Sim

Russell Sim added the comment:

Raymond, Thanks for the comprehensive feedback! It's fantastic!  I have updated 
the patch with most of you feedback... but there was one part that I couldn't 
follow entirely.  I am now using the _make method but I have had to use star 
unpacking to allow the method to be cached, lru_cache won't allow a key to be a 
list because they aren't hash-able.

--
Added file: http://bugs.python.org/file26945/issue_13299.1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13299
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13299] namedtuple row factory for sqlite3

2012-08-21 Thread Russell Sim

Russell Sim added the comment:

Nick, Thanks for the tip.  I have removed the star unpacking.

--
Added file: http://bugs.python.org/file26946/issue_13299.2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13299
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13299] namedtuple row factory for sqlite3

2012-08-19 Thread Russell Sim

Russell Sim added the comment:

Hi,

Here is an implementation using lru_cache to prevent regeneration of the named 
tuple each time.

Cheers,
Russell

--
keywords: +patch
nosy: +Russell.Sim
Added file: http://bugs.python.org/file26909/issue_13299.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13299
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13720] argparse print_help() fails if COLUMNS is set to a low value

2012-07-21 Thread Russell Sim

Russell Sim russell@gmail.com added the comment:

Hi,

I am having the same problem while running ipython in a batch mode emacs.  
Apparently you can't even start ipython if the columns are less than 27, since 
they use the argparse library for the magic method help printing and they 
preformat the strings at import time. So importing the library fails. :(

I have a simple patch that fixes it but from what i can tell if you set the 
columns to 10 or 1000 there is no effect on the output, so i wonder if it even 
pays any attention to the width during rendering.

If you think it's of value I am happy to write tests. Or if someone has a 
better implementation idea I'll be happy to implement it, but if you are on a 
terminal that is getting 27 characters then you can't really expect the 
formmating of the messages to be that readable.

--- cpython/Lib/argparse.py 2012-07-22 12:10:42.751869655 +1000
+++ /tmp/ediff3953qkY   2012-07-22 12:54:51.380700044 +1000
@@ -95,6 +95,7 @@
 def _callable(obj):
 return hasattr(obj, '__call__') or hasattr(obj, '__bases__')
 
+MIN_WIDTH = 10
 
 SUPPRESS = '==SUPPRESS=='
 
@@ -486,7 +487,10 @@
 # determine the required width and the entry label
 help_position = min(self._action_max_length + 2,
 self._max_help_position)
-help_width = self._width - help_position
+if self._width - help_position  MIN_WIDTH:
+help_width = self._width - help_position
+else:
+help_width = MIN_WIDTH
 action_width = help_position - self._current_indent - 2
 action_header = self._format_action_invocation(action)

--
nosy: +Russell.Sim
versions: +Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com