Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Maya Basics & Newbie Lounge (https://simplymaya.com/forum/forumdisplay.php?f=31)
-   -   Anyone know Python? Technical question. (https://simplymaya.com/forum/showthread.php?t=33820)

elephantinc 26-02-2010 08:26 PM

Anyone know Python? Technical question.
 
Does anyone know how to call a function thats defined with in a class? I've tried myclass.myfunction() but that doesn't seem to work.

Any help will be greatly appreciated.
ElephantInc

stwert 26-02-2010 09:58 PM

That should be about right. Are there any parameters you need to specify, such as myclass.myfunction(var1)? What error message are you getting?

Oh yeah, and have you imported the class in your script?

elephantinc 26-02-2010 10:46 PM

error:
File "/Users/Elephant_Inc/Desktop/PhAT/main.py", line 270, in <module>
commText.update(timer)
TypeError: unbound method update() must be called with commText instance as first argument (got int instance instead)

My class is commText and the function is update (that needs the timer variable)
this is the line I'm using to call it: commText.update(timer)

ctbram 26-02-2010 11:40 PM

looks like you have not instantiated the commText class unless it is a static class you must instantiate it.

I have used python bit the syntax would be something like...

...
x = commText()
x.update(timer)
...

elephantinc 27-02-2010 12:00 AM

Thanks that worked :)
I thought just doing

commText()
commText.update(timer)

would work.

:beer:


All times are GMT. The time now is 04:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018