On this page
  1. shelve.Shelf
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

shelve.Shelf

Prev: shelve.open | Up: shelve
Rel: shelve.BsdDbShelf, shelve.DbfilenameShelf, shelve.open
Ref: docs.python.org — shelve.Shelf
Tags: #public #python3 #stdlib #shelve


Import

import shelve
from shelve import Shelf

Signature & Overview

shelve.Shelf(dict, protocol=None, writeback=False, keyencoding='utf-8')

Base class for shelf implementations.

Methods & Attributes

Usage

import shelve

# Wrap any bytes->bytes mapping with pickle serialization
backing: dict[bytes, bytes] = {}
with shelve.Shelf(backing) as s:
    s['k'] = [1, 2, 3]
    assert s['k'] == [1, 2, 3]

Gotchas

REPL Inspect

from shelve import Shelf
help(Shelf)

Linked from

Related notes