I don´t know why my result "is not defined" by the way,
I thought it would work using __import__ inside a def..
def importModule(modules):
for mod in modules:
try:
module = __import__(mod)
for d in module.__dict__:
print mod, d, '\n'
except ImportError:
print "Unable to import %s" % (mod)
##
importModule(["maya.cmds"])
maya.cmds.getAttr("someObj.tx")
# Error: NameError: name 'maya' is not defined #
On Fri, Aug 5, 2011 at 1:26 PM, Renato Polimeno <[email protected]>wrote:
> Hey guys, I´m starting digging out some python codes and I´m testing out my
> own def to 'batch import' necessary modules... ie.
>
> def importModule(modules):
> try:
> for mod in modules:
> module = __import__(mod)
> for d in module.__dict__:
> print 'module= ', mod, 'dict=', d, '\n'
> #
> except ImportError:
> print "Unable to import %s" % (modules)
> #
>
> Using importModule(["maya.cmds","pymel.core"]) works fine.. But how could I
> implement a list of strings more efficient like "import maya.cmds as cmds"
> or "from pymel.core import *" ?
> Do you guys use something like this or is it better to keep it simple and
> standard?
>
> Thanks,
>
> --
> ______________________________
>
> -> Renato Polimeno
> +55 11 7539 3615
> renatopolimeno.com <http://www.renatopolimeno.com>
>
> <http://www.renatopolimeno.com/>facebook.com/renato.polimeno<http://www.facebook.com/renato.polimeno>
> @renatopolimeno <http://www.twitter.com/renatopolimeno>
>
>
>
--
______________________________
-> Renato Polimeno
+55 11 7539 3615
renatopolimeno.com <http://www.renatopolimeno.com>
<http://www.renatopolimeno.com/>facebook.com/renato.polimeno<http://www.facebook.com/renato.polimeno>
@renatopolimeno <http://www.twitter.com/renatopolimeno>
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe