Python import as Keyword
Using import [module name] as [alias]
will import the Python module and alias the module name.
Python
Copy Code
import myModule as myAlias
Example
Let's say you have a file called "moduleToImport.py" that looks like this:
Python
Copy Code
class ImportedClass(): def sayHello(self): print('hello')
the module name is "moduleToImport" which can be used like this:
Python
Copy Code
import moduleToImport as m myImportedClass = m.ImportedClass() myImportedClass.sayHello()
Output
Hello
Notice how "m" aliases the module name "moduleToImport."