Jump to content
  • Advertisement
Sign in to follow this  
V-man

Python functions

This topic is 3856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So this is a Python member function?
class OSG:
    def makeGroup(self, name, uniqueID, children):
        text = ["Group {"];
        text = text + self.makeGroupContents(name, uniqueID, children);
        text.append("}")
        return text;



At the end of text.append("}") there is a ";" missing. Is that ok in python? I don't know exactly what self is but whatever. It looks like it is allocating some memory for OSG.
self.osg=OSG();



Here it looks like a parameter to function makeGroup is missing. Is that legal in Python?
self.osg.makeGroup("Blender root", "BlenderRoot", roots);



Share this post


Link to post
Share on other sites
Advertisement
you do not need semicolons to end lines in python.
self is like the this pointer in C++, it is a reference to the object that is currently having its function called. It is listed as a parameter, but you don't need to pass it. Also, you don't technically need to call it 'self', but it is recommended because everyone else does it.

learn:
http://docs.python.org/tut/

Share this post


Link to post
Share on other sites
yes,

no semicolons needed in python to end lines

you shouldn't need to pass the self parameter around

so basically I reiterated what the poster before me said

Share this post


Link to post
Share on other sites
Seriously, don't try to learn Python from code, go visit Dive Into Python or read another Python tutorial. This would all be covered in a section on classes.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!