Skip to main content

Understand what is in your ipython playground.

Project description

Release Notes Downloads GitHub CI Status License: MIT

IPython Playground

I'm a big fan of playgrounds. Every repo should have a playground.py to make it easy to jump right into REPL-driven development.

However, it's hard to understand what's in the playground.py once it gets big. This project eliminates this problem (example from this project):

alt text

Installation

uv add ipython-playground

Usage

  1. Run ipython-playground to generate a playground.py.
  2. Execute ./playground.py to start an IPython session with additional setup.

How extras.py and the all() hook work

The ipython_playground/extras.py file provides logic to automatically import and expose useful modules and objects in your playground session. The main entry point is the all() function, which:

  • Loads common app modules (like app.models, app.commands, app.jobs) if available.
  • Monkey patches Enum.__repr__ to provide a cleaner, concise display of enum members in the REPL (e.g. MyEnum.MEMBER instead of <MyEnum.MEMBER: 1>).
  • Attempts to import helpful libraries such as funcy_pipe, sqlalchemy, and sqlmodel.
  • Optionally discovers all SQLModel classes in your models module and adds them to the namespace.
  • If a database URL is available (either passed in or imported from your app config), sets up a SQLAlchemy engine and session, and exposes helpers for running and compiling SQL statements.

When you run playground.py, it calls globals().update(ipython_playground.all_extras()), which injects all these objects into your interactive session, making them immediately available for experimentation.


This project was created from iloveitaly/python-package-template

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipython_playground-0.7.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipython_playground-0.7.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file ipython_playground-0.7.0.tar.gz.

File metadata

  • Download URL: ipython_playground-0.7.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ipython_playground-0.7.0.tar.gz
Algorithm Hash digest
SHA256 4b6432c6b0cef7e88c90a766d5cee293f15dadec9fc65e7b12a0724cb33562e6
MD5 c0627e2764f25d0e924e04d2d8388294
BLAKE2b-256 c85055118cd287fb7f9a260ab0cb3fa550e572f7ec7231696ff6580e9348a3b2

See more details on using hashes here.

File details

Details for the file ipython_playground-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: ipython_playground-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ipython_playground-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48c729d545f13693d6c4229542c4233051d09bff5bdc524d2e001d2f1c888c06
MD5 074a011d3622d4aae329b0e36b53539c
BLAKE2b-256 3e77231ebc697b5ea7171b7d5b9c6c6225736813b79a43535d37f0b785bbae5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page