when import is required the only time you really must use import instead of from is when you must use the same name defined in two different modules for exampleif two files define the same name differentlym py def func()do something py def func()do something else and you must use both versions of the name in your programthe from statement will fail--you can have only one assignment to the name in your scopeo py from import func from import func func(this overwrites the one we fetched from calls func onlyan import will work herethoughbecause including the name of the enclosing module makes the two names uniqueo py import mn func( func(get the whole modulesnot their names we can call both names now the module names make them unique this case is unusual enough that you're unlikely to encounter it very often in practice if you dothoughimport allows you to avoid the name collision another way out of this dilemma is using the as extensionwhich we'll cover in but is simple enough to introduce hereo py from import func as mfunc from import func as nfunc mfunc()nfunc(rename uniquely with "ascalls one or the other the as extension works in both import and from as simple renaming tool (it can also be used to give shorter synonym for long module name in import)more on this form in module namespaces modules are probably best understood as simply packages of names-- places to define names you want to make visible to the rest of system technicallymodules usually correspond to filesand python creates module object to contain all the names assigned in module file but in simple termsmodules are just namespaces (places where names are created)and the names that live in module are called its attributes this section expands on the details behind this model module coding basics