wbolster / plyvel

Plyvel, a fast and feature-rich Python interface to LevelDB
https://plyvel.readthedocs.io/
Other
530 stars 75 forks source link

Add __repr__() for DB and PrefixedDB objects #16

Closed wbolster closed 10 years ago

wbolster commented 10 years ago

The __repr__() should include the database name, the state (open/closed) and (if applicable) the prefix.

wbolster commented 10 years ago

Sample output with the changes introduced in commit b2e75b4:

>>> import plyvel
>>> db = plyvel.DB('/tmp/testdb', create_if_missing=True)
>>> db
<plyvel.DB with name '/tmp/testdb' at 0x0x2243b78>
>>> db.prefixed_db(b'foo')
<plyvel.PrefixedDB with prefix 'foo' at 0x0x234ad10>
>>> db.close()
>>> db
<plyvel.DB with name '/tmp/testdb' (closed) at 0x0x2243b78>