I am new-ish to programming and have a question about the way Python packages and modules are organized and are accessed. I was trying to get a function to calculate permutations and found scipy.special.perm. My first intuition was that scipy was the module, special was the class, and perm was the function. So I tried this (1):
import scipy
scipy.special.perm(5, 4)
But I got the error:
AttributeError: module 'scipy' has no attribute 'special'
This is what worked (2):
import scipy.special
scipy.special.perm(5,4)
- Why did (1) fail?
- I am trying to understand conceptually how scipy is built/organized. Is scipy a package or a module? After all the error message did refer to it as a module so I am leaning towards the latter.
- What is scipy.special then? Is it a module?
- What is the recommended way to 'explore' a new module/package like scipy to understand its nature and how it needs to be called so that I now whether to use (1) or (2)?