- attached testcase.py
patch for RowProxy objects to support slicing
Since a RowProxy object supports accessing its items by integer index, and generally emulates almost all tuple behavior, it ought to support slicing, too.
resultrow = mytable.select().execute().fetchone() resultrow0 works, but resultrow:0 fails with TypeError: unhashable type
I'm attaching a simple patch to /engine/base.py. With the patch, slicing a RowProxy object returns a tuple, exactly as if it were the tuple it appears to be. Arguably, the slice should itself be a RowProxy, but implementing that gets complicated.
Comments (6)
-
Account Deleted -
Account Deleted - attached FileComparisonDiffReport.txt
UNIX diff file with my patch. I'm not sure it caught the indentation in line 1175 properly, though.
-
Account Deleted - attached base.py
My patched version of base.py, modified from revision 3038 in the svn repository.
-
Account Deleted Oops, forgot to identify myself - this is Catherine Devlin, catherine.devlin -- gmail.com
My patch is pretty much cribbed straight from the suggested use of extended slices at http://www.python.org/doc/2.3.5/whatsnew/section-slices.html applied to the RowProxy.getitem
-
repo owner - changed status to resolved
adjusted to work with 2.3 (no generators) and patched in changeset:3054, thanks !
-
repo owner - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment
test case