I understand that when possible one should use
import numpy as np
This helps keep away any conflict due to namespaces. But I have noticed that
This is a language feature. f2py is a subpackage of the module numpy and must be loaded separately.
This feature allows:
numpy only the packages you need, speeding up execution.f2py to have namespace separation from the developers of another subpackage.Notice however that import numpy.f2py or its variant import numpy.f2py as myf2py are still loading the parent module numpy.
Said that, when you run
import numpy as np
np.f2py
You receive an AttributeError because f2py is not an attribute of numpy, because the __init__() of the package numpy did not declare in its scope anything about the subpackage f2py.