Metadata-Version: 2.4
Name: ipython-playground
Version: 0.4.0
Summary: Understand what is in your ipython playground.
Project-URL: Repository, https://github.com/iloveitaly/ipython-playground
Author-email: Michael Bianco <mike@mikebian.co>
License: MIT
License-File: LICENSE.md
Keywords: ipython,playground,repl
Requires-Python: >=3.9
Requires-Dist: rich>=13.9.4
Description-Content-Type: text/markdown

# 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](https://github.com/iloveitaly/python-starter-template)):

![alt text](screenshot.png)

## Installation


```shell
pip install 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.
- 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.
