In the second example you still have to use nameOfmodule.someMethod(...)
when you want to call method, in the first you simply need someMethod(..). If you used import nameOfmodule.someMethod as sm
that would make more sense.
If you like typing or you have another someMethod
defined somewhere in your code use your second example.
An example using os.path
:
In [3]: import os.path
In [4]: os.path.abspath(".")
Out[4]: '/home/foo'
In [5]: from os import path
In [6]: path.abspath(".")
Out[6]: '/home/foo'
In [7]: import os.path as op
In [8]: op.abspath(".")
Out[8]: '/home/foo'
The clr is only relevant if you are using Ironpython
:
The import statement in Python is more analogous to a using statement in C#. you still need to load the relevant .dll assembly. C# does this at compile-time by using references; IronPython by default includes standard CLR references, which is why it is immediately possible to import System.Xml
However, if you want to load a .dll that is not included by default in IronPython, you must use clr.AddReference("myAssembly.dll") and then use the import statement to import the module.
There a a blog post here that goes into more detail