On Mon, 1 Jun 2015 9:41 PM Rémi Deletrain <[email protected]> wrote:
try this
class test(object):
def __init__(self,x,y):
self.x=x
self.y=y
def info(self):
print "%s,%s"%(self, self.x, self.y)
ok=test("pSphere1","pSphere2")
test().info <http://test.info/>()
if you want call info with no instance add a decorator '@classmethod' and
change 'self' by 'cls' before your function
@classmethod
def info(cls):
print "%s,%s"%(self, self.x, self.y)
This is an error. "self" is not defined. And if you switch it to "cls" it
will still be an error because x and y are instance variables
--
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/70f3e4b6-0b41-4c5d-820f-5899c6d2646e%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/70f3e4b6-0b41-4c5d-820f-5899c6d2646e%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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/CAPGFgA2RoPibZh9_sRVrxLmJn8LTK%3D9wmLsq3QeZHzJ%3DeY2RmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.