[issue21670] Add repr to shelve.Shelf

2014-06-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I don't think this is right repr for shelve. As file's repr doesn't read and 
expose a content of a file, shelve's repr shouldn't read and expose all 
database content.

--
nosy: +serhiy.storchaka

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



[issue21670] Add repr to shelve.Shelf

2014-06-24 Thread Claudiu Popa

Claudiu Popa added the comment:

Fair point, Serhiy. But I see the shelve more similar to a persistent, 
dictionary-like object, than to a file. The fact that it uses some database 
behind is just an implementation detail.

--

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



[issue21670] Add repr to shelve.Shelf

2014-06-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

When shelve stores its data on a disk, it is more similar to a file. After all, 
it can contain gigabytes of data, much larger than Python can address in RAM.

I you want more readable repr, I with Raymond, -- use the repr of the 
underlying db and add readable repr for dbm objects (including file name and 
open mode).

--

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



[issue21670] Add repr to shelve.Shelf

2014-06-24 Thread Claudiu Popa

Claudiu Popa added the comment:

Alright, I agree with you now. You can close the issue if you want.

--

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



[issue21670] Add repr to shelve.Shelf

2014-06-24 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
resolution:  - wont fix
status: open - closed

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



[issue21670] Add repr to shelve.Shelf

2014-06-24 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
stage: patch review - resolved

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



[issue21670] Add repr to shelve.Shelf

2014-06-22 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
assignee:  - rhettinger
nosy: +rhettinger
stage:  - patch review

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



[issue21670] Add repr to shelve.Shelf

2014-06-22 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This may not be the right repr for the usual way of creating shelves:

d = shelve.open('tmp.shl')
print(repr(d)) # I would expect the repr to show 
   # the underlying db instead of all the
   # key/value pairs which can be passed
   # in the constructors

--

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



[issue21670] Add repr to shelve.Shelf

2014-06-22 Thread Claudiu Popa

Claudiu Popa added the comment:

The problem is that the repr of the underlying db is not very helpful either, 
as seen for the dbm backend.

 import dbm
 dbm.open(test, c)
dbm.dumb._Database object at 0x03091FC0
 f=_
 f[b2] = ba
 f
dbm.dumb._Database object at 0x03091FC0


But it shows the content of the underlying database, not the key / value pairs 
passed in the constructor:

 shelve.open(test1)
DbfilenameShelf({})
 f=_
 f[2] = 4
 f
DbfilenameShelf({'2': '4'})
 f[40] = 50
 f.dict
dbm.dumb._Database object at 0x02ACC038
 f.dict.keys()
[b'40', b'2']


--

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



[issue21670] Add repr to shelve.Shelf

2014-06-05 Thread Claudiu.Popa

New submission from Claudiu.Popa:

Hello!

Working with Shelf instances in the interactive console is cumbersome because 
you can't have an instant feedback when running the following:

 from shelve import Shelf
 s = Shelf({})
 s['a'] = 1
 s
shelve.Shelf object at 0x033D0AF0

This patch adds an useful repr to Shelf objects.

 s
Shelf({'a': 1})

Thanks!

--
components: Library (Lib)
files: shelve.patch
keywords: patch
messages: 219827
nosy: Claudiu.Popa
priority: normal
severity: normal
status: open
title: Add repr to shelve.Shelf
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file35492/shelve.patch

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