Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 13 Online
OpenStudy (anonymous):

A small piece of code for pset 5: http://dpaste.com/773055/ peaking at the sample solution i have two questions: 1. what is the function of 'self'.word? (by that i mean the function of the word 'self' here, as opposed to just 'word', which is what i had at first). (2. I just understood the second question as i was posing it:) i also corrected line 15 in the script i posted... ) thanks!

OpenStudy (anonymous):

well ... i'm sure other people can say it better: http://effbot.org/pyfaq/why-must-self-be-used-explicitly-in-method-definitions-and-calls.htm "Often, the first argument of a method is called self. This is nothing more than a convention: the name self has absolutely no special meaning to Python. Note, however, that by not following the convention your code may be less readable to other Python programmers, and it is also conceivable that a class browser program might be written that relies upon such a convention." from: http://docs.python.org/tutorial/classes.html#random-remarks unrelated but a good resource (as is effbot) http://en.wikibooks.org/wiki/Python_Programming/Classes

OpenStudy (anonymous):

Ok, i'm starting to understand. Self is something that just refers to the class' members (or perhaps rather its initializing functions objects) themselves. it's the name of an argument that refers to an object not yet created, is that correctly understood? is that what Guttag means when he says it is a formal parameter without an actual parameter?

OpenStudy (anonymous):

self is its self ??

OpenStudy (anonymous):

I don't really understand how it works with this self; what it refers to, when you need to use it, when you use it out of convention and so on. so i read through the links, the lecture notes and one of the things i thought i understood, was that self refers to the members of the class before we know what they are. which is still weird. but i thought that was a sort of first way of understanding what's going on. i can see how it sounds confused to you:)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!