In irb we can do:
>> load 'example.rb'
Which loads the source of example.rb
in to environment.
What is alternative for bpython and ipython?
Assuming you have a file called example.py that exists somewhere in your PYTHONPATH (much like ruby's $LOAD_PATH)
In normal python: Details here
>>> import example # Import module.
>>> example.hello() # Run code
hello
# Then, lets say you change the hello function to say "hello world, I'm changed!"
>>> reload(example)
<module 'example' from 'example.pyc'>
>>> example.hello()
hello world, I changed!
IPython has all of the above with the addition of other ways.
dreload is like reload, but recursively reloads modules that example.py imports. This means that if example.py was dependent on example2.py and you changed example2.py, example.example2 would reflect the updated changes
In [5]: dreload(example) # (after import, of course)
In [6]: dreload? # Details...
%run magic is my favorite, because it executes the file called and then embeds that file's namespace into your current session. It implies reload and dreload when it's called, and also works like import *. I'd say it's the most like ruby's "load."
In [1]: %run example.py
In [2]: hello()
hello
# Make some changes to code
In [3]: %run example.py
hello world, I changed!
In [4]: %run? # Details...
from this import *
Will load the content of this.py
into your current namespace.