5

Is it possible to start the bpython interpreter so that it always runs some custom commands when it launches?

In my case I simply want to do:

import numpy as np
import matplotlib.pyplot as plt

I can't see anything in the docs. Anyone know a way?

2 Answers 2

5

It is written in the docs, just not clearly labelled as such at: http://docs.bpython-interpreter.org/django.html

Gist of it is you can have an environment variable called PYTHONSTARTUP. bpython will execute this file before you get dropped in the interpreter.

Sign up to request clarification or add additional context in comments.

Comments

0

While ikanobori's answer is the way to go here, I thought I show another simple alternative.

import numpy as np
import matplotlib.pyplot as plt
import bpython
bpython.embed(locals_=locals())

This will start up the bpython REPL and load in the local variables and other symbols. This would be useful if you wanted to have more than one customized shell.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.