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
numpy is the top package name, and doing import numpy
doesn't import submodule numpy.f2py
.
When you do import numpy
it creats a link that points to numpy
, but numpy
is not further linked to f2py
. The link is established when you do import numpy.f2py
In your above code:
import numpy as np # np is an alias pointing to numpy, but at this point numpy is not linked to numpy.f2py
import numpy.f2py as myf2py # this command makes numpy link to numpy.f2py. myf2py is another alias pointing to numpy.f2py as well
Here is the difference between import numpy.f2py
and import numpy.f2py as myf2py
:
import numpy.f2py
import numpy.f2py as myf2py