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?

YXD
  • 31,741
  • 15
  • 75
  • 115

2 Answers2

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.

supakeen
  • 2,876
  • 19
  • 19
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.

jrdmcgr
  • 1,681
  • 3
  • 13
  • 13