Bpython configuration - import numpy and matplotlib by default

Is it possible to run the bpython interpreter so that it always runs some user commands at startup?

In my case, I just want to do:

import numpy as np import matplotlib.pyplot as plt 

I don't see anything in docs . Does anyone know a way?

+4
source share
2 answers

This is written in documents that are simply not designated as such: http://docs.bpython-interpreter.org/django.html

Its essence is that you can have an environment variable called PYTHONSTARTUP . bpython will execute this file before you fall in the interpreter.

+5
source

Although ikanobori's answer is the way here, I thought I was showing another alternative.

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

This will run bpython REPL and load local variables and other characters. This would be useful if you would like to have more than one custom shell.

0
source

Source: https://habr.com/ru/post/1394384/


All Articles