Yes, the approach only works if the scripts have no relation and if they don’t need access to a currently running environment, like Maya.
If you have control of how the scripts it is meant to run are developed, a common interface should do the trick. Here’s an example of how this works in Pyblish. import pyblish.api # find all scripts, and return their common interface;# a class called "Plugin" in this casefor plugin in pyblish.api.discover(): plugin_ = plugin() instantiated.process() It takes all scripts it finds on paths registered by someone else, and expects those scripts to contain a subclass of a particular superclass provided by the framework; the Plugin class. - pyblish.api.discover() <https://github.com/pyblish/pyblish/blob/0fcf37a0b251f811f1071c858b723dc5065983a8/pyblish/plugin.py#L1036> - pyblish.api.Plugin.process() <https://github.com/pyblish/pyblish/blob/0fcf37a0b251f811f1071c858b723dc5065983a8/pyblish/plugin.py#L288> You could do something similar or maybe even identical to this, as this is also affecting the internal state of Maya and also deals with side-effects, using execfile as opposed to import. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAVi2hLcxA9VtFvMsTmA_SXzec-Ax%3DmBr3dME0ZP8YkYQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
