You almost have the whole thing correct, except for how you end up calling
the method. A method is "bound" to a specific instance of a class.

# "ok", while not a very descriptive name, is now an instance of class
"test"
ok = test("pSphere1", "pSphere2")

# call a method on your instance
ok.info()

On Mon, 1 Jun 2015 9:16 PM Sumant Shenoy <[email protected]> wrote:

> i am trying to learn classes but i keep getting this errror can any one
> tell me what am i doing wrong
>
>  line 10: unbound method info() must be called with test instance as first
> argument (got nothing instead)
> 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()
>
>  --
> 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/CAGhqNnmE5FHP4xtxdF6rgrfSh4B7SFNNHsdmfOOdbYP_0d9%2BUQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAGhqNnmE5FHP4xtxdF6rgrfSh4B7SFNNHsdmfOOdbYP_0d9%2BUQ%40mail.gmail.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/CAPGFgA15h756zADWLHCMm8gwZK00bVPY_mORuzONyjSPF8KzLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to