import - What are the rules for importing with "as" in Python without using from -


i trying import following function in python 2.7

import scipy.signal.savgol_filter sgolay 

i received following error:

importerror: no module named savgol_filter 

savgol_filter function, not module, error makes sense. question is, not possible import, without use of word "from" besides module?

in other words, following works:

from scipy.signal import savgol_filter sgolay 

but in general, following "sub_part" need module?

import my_module.sub_part some_name 

i've seen lots of writing suggesting "sub_part" not need module. there tricky going on scipy making not work?

thanks,

jim

in general, if import thing, import thing.subthing, import thing.subthing.subsubthing, etc., far-right thing needs module. from form allows importing things aren't modules. if want definitive statement of forms of import statement , allows, python language reference explains in great detail, it's pretty dense read.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -