Moppentapper - 1 year ago 66

Python Question

I'm still fairly new to python and am wondering if the x.y statement means y is a submodule of x? And if so, doesn't the command:

`import matplotlib.pyplot as plt`

only import this particular submodule and nothing else? I had to do this in order to get access to the

`hist`

`import matplotlib as plt`

I'm aware that this question is related to what is the difference between importing python sub-modules from NumPy, matplotlib packages But the answer in this question does not tell me if nothing else in matplotlib is imported and how to just import all of matplotlib without worrying about submodules being left out.

Answer

I don't know of any way to import all the functions from every submodule. Importing all the functions from a submodule is possible the way you suggested with e.g. `from matplotlib.pyplot import *`

.

Be noted of a potential problem with importing every function; you may override imported functions by defining your own functions with the same name. E.g:

```
from matplotlib.pyplot import *
def plot():
print "Hello!"
plot()
```

would output

```
Hello!
```