Understanding importing python/pymel modules


#1

Hi all,

I notice in my Maya installation that there is a folder structure:

pymel/core

And the folder “core” contains various .py files such as “general”.

I thought that in Python, when you import a module, you are importing a “.py” file.

So how is it possible to execute the code “import pymel.core as pm”, and then use pm to use the various functions in for example “general.py” files?

Thanks.


#2

Python isn’t Maya-specific, so there are lots of learning resources for it. Tthe Python module and package tutorial talks about this:

https://docs.python.org/2/tutorial/modules.html#packages


#3

@cybercreature python modules can be folders as well, you might notice in folders relating to python the existence of a file that is init.py in folders. if that exists it makes the folder a module and it can also have some additional imports or code to defined in it, when that module is imported.