module/function naming conventions

84 views
Skip to first unread message

s...@weacceptyou.com

unread,
May 21, 2016, 7:15:47 PM5/21/16
to Python Programming for Autodesk Maya
hi there.

i have been reading the python document on naming conventions to try and avoid clashes when import modules and classes with the same names.

i am able to import a function from a module with the same name as the module eg

from samDev.rigging.TOPOCOAT.configure import configure

(the second 'configure' being a def inside the 'configure.py' module). However if i update this function and use the reload command:

reload (configure)

i think python is confusing the 'configure' module name with the function, resulting in this error:

# TypeError: reload() argument must be module #

If there was different casing for the module name and the function name it would work. But apparently it is convention for modules and functions to be in lower case. Is there a way around this. Or should i just rename the function to something else?

thanks,
Sam

Justin Israel

unread,
May 21, 2016, 8:24:23 PM5/21/16
to Python Programming for Autodesk Maya

If you plan to use the reload() function, then don't use the "import from" syntax. You only want the symbol for the module and not to hold onto any symbols from that module. Otherwise when you reload, you will still have old symbols.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a5a694ca-8754-4c46-ac47-11fc3a21a77d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Cesar Saez

unread,
May 22, 2016, 2:04:46 AM5/22/16
to python_in...@googlegroups.com

Also having to repeat the name everywhere kinda sucks, I would recommend to start from the usage code and find a way to make that interface possible (aggregating symbols in an dounder init module or simply picking better names).

I.e.
import awesomeness

awesomeness.configure()
awesomeness.run()

s...@weacceptyou.com

unread,
May 22, 2016, 7:44:33 AM5/22/16
to Python Programming for Autodesk Maya
great thanks for the help ;)
Reply all
Reply to author
Forward
0 new messages