PyperCard is a simple HyperCard inspired framework for PyScript for building graphical apps in Python.

Based on original pre-COVID work by Nicholas H.Tollervey.

Copyright (c) 2023 Anaconda Inc.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Module Contents



A simple key/value data store.


class pypercard.datastore.DataStore(**kwargs)

A simple key/value data store.

Wraps a JavaScript Storage object for browser based data storage. Looks and feels mostly like a Python dict but has the same characteristics as a JavaScript localStorage object.

For more information see:


The underlying Storage object is an instance of Window.localStorage (it persists between browser opening/closing). Any **kwargs are added to the dictionary. All keys are silently prepended with the value of self.namespace.


Removes all items from the data store.


Returns a Python dict copy of the data store.

get(key, default=None)

Return the value of the item with the specified key.


Yield over the key/value pairs in the data store.


Returns a list of keys stored by the user.

pop(key, default=None)

Pop the specified item from the data store and return the associated value.

abstract popitem()

Makes no sense given the underlying JavaScript Storage object’s behaviour. Raises a NotImplementedError.

setdefault(key, value=None)

Returns the value of the item with the specified key.

If the key does not exist, insert the key, with the specified value.

Default value is None.


For each key/value pair in the iterable, insert them into the data store.


Return a list of the values stored in the data store.


Convenience method to create a properly namespaced key.


The number of items in the data store.


Get and JSON deserialize the item stored against the given key.

__setitem__(key, value)

Set the value (as a JSON string) against the given key.

The underlying JavaScript Storage only stored values as strings.


Delete the item stored against the given key.


Return an iterator over the keys.


Checks if a key is in the datastore.