Data

Local Storage

set_item()

p5.set_item(key, value)
  • Stores a value in local storage under the key name.
  • Local storage persists in between the p5py sketch sessions.
  • The key can be the name of the variable but doesn’t have to be.
  • Sensitive data such as passwords or personal information should not be stored in local storage.
  • Overwrites the key if already present
Parameters:
  • key (basestring) – key name that you wish to you use in local storage
  • value (object) – Value to be stored, can be of any type

get_item()

p5.get_item(key)

Returns the value of an item that was stored int local storage using store_item(), None if not found

Parameters:key (string) – key name that was used while storing data using store_item()
Returns:Value of stored item
Return type:object

remove_item()

p5.remove_item(key)

Removes an item that was stored with store_item()

Parameters:key (string) – key name to remove the associated value

clear_storage()

p5.clear_storage()

Clears all storage items set with store_item()