modules
Title
Question
why do we use numpy.pi or plt.plot instead of just pi or plot?
Python-3.4.3 Using-Python-Modules 06-07 min 0-10 sec
Answers:
When you type ipython --pylab you get all the functions preloaded in the ipython terminal.
In case of modules i.e. the python script you need to import the functions beacuse unlike ipython the module file does no load the modules automatically.
If you still do not want to import and run the code then type
1. ipython --pylab in the windows command prompt/linux terminal.
2. %run -i filename.py inside ipython terminal.
This won't throw any error even if you use just pi or plot because the modules are already loaded in the ipython terminal.
But if you try to run the file as python filename.py then it will throw error saying function not found etc. In order to avoid errors you need to import the functions before the code.
Login to add comment