Python built in function, type(), not working in maya?

167 views
Skip to first unread message

Bryan Silva

unread,
Sep 27, 2015, 10:06:00 PM9/27/15
to Python Programming for Autodesk Maya

I've been reading "Maya Python for Games and Films" and I’m having trouble with something mentioned on page 32. The book mentions that python provides a built in function, type(), which allows you to determine the type of a variable at any point. Whenever I try to execute that function with a variable inside the parenthesis, I get an error in Maya. An example would be:


contents = ‘toys’
type(contents)
# Error: TypeError: file line 2: ‘module’ object is not callable #


I'm actually further along in the book on page 65 where I'm trying to following along but running into the following:


def process_all_textures():
    print(‘process all textures’)

type(process_all_textures)
# Error: TypeError: file line 4: ‘module’ object is not callable #


Any idea why I am getting this error? Other built in Python functions such as id() work just fine.

Justin Israel

unread,
Sep 27, 2015, 10:10:43 PM9/27/15
to Python Programming for Autodesk Maya
Did you accidentally shadow the "type" symbol with something of your own? What do you see when you do:

print type



--
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/553d65d8-d08d-4bf0-bfee-3dcc597c54cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bryan Silva

unread,
Sep 27, 2015, 10:13:38 PM9/27/15
to Python Programming for Autodesk Maya
when I print type I get the following:

<module 'maya.app.type.AEtypeTemplate' from 'C:\Program Files\Autodesk\Maya2017\Python\lib\site-packages\maya\app\type\AEtypeTemplate.py'>

Bryan Silva

unread,
Sep 27, 2015, 10:15:04 PM9/27/15
to Python Programming for Autodesk Maya
but when I print id I get the following:

<built-in function id>

Justin Israel

unread,
Sep 27, 2015, 10:16:25 PM9/27/15
to Python Programming for Autodesk Maya
Yep. It looks like you probably did some kind of "*" import, and brought a bunch of symbols from the maya module into your root namespace. Do you happen to have code like this?

from maya.app import *

If so, don't do that. Do something like:

import maya.app as m_app

Or some variation of a symbol that doesn't clash with others that you use. Then you should be able to access all the symbols in that one and avoid namespace clashes.


On Mon, Sep 28, 2015 at 3:13 PM Bryan Silva <135.bry...@gmail.com> wrote:
when I print type I get the following:

<module 'maya.app.type.AEtypeTemplate' from 'C:\Program Files\Autodesk\Maya2017\Python\lib\site-packages\maya\app\type\AEtypeTemplate.py'>

--
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.

Bryan Silva

unread,
Sep 28, 2015, 9:28:54 AM9/28/15
to Python Programming for Autodesk Maya
Thanks for the info. Strange because its from nothing that I have created myself. I just tried out using the type() function in an older version of maya that I have and it worked fine. Where I'm having the trouble is with a beta version of the software. 

Adam Mechtley

unread,
Sep 28, 2015, 11:42:03 AM9/28/15
to python_in...@googlegroups.com
Looks like this is the problem (from AEtypeTemplate.py):

import maya.app.type.typeUtilityScripts as type

I'll report it

On Mon, Sep 28, 2015 at 8:28 AM, Bryan Silva <135.bry...@gmail.com> wrote:
Thanks for the info. Strange because its from nothing that I have created myself. I just tried out using the type() function in an older version of maya that I have and it worked fine. Where I'm having the trouble is with a beta version of the software. 

--
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.

Fredrik Averpil

unread,
Sep 28, 2015, 2:56:57 PM9/28/15
to python_in...@googlegroups.com
I've used type() extensively in Maya and I never saw that error.
Reply all
Reply to author
Forward
0 new messages