Thanks!
I remember the time that I had no idea how classes worked. Always tried to grasp them in PHP but because they weren't forced I never used them.
I recommend learning Java for a while. It's where I really learned how to use classes and understand them the best. Or just ask away, we can answer your questions
Alright
Well, this example from learn python the hard way:
class Song(object):
def __init__(self, lyrics):
self.lyrics = lyrics
def sing_me_a_song(self):
for line in self.lyrics:
print line
happy_bday = Song(["Happy birthday to you",
"I don't want to get sued",
"So I'll stop right there"])
bulls_on_parade = Song(["They rally around the family",
"With pockets full of shells"])
happy_bday.sing_me_a_song()
bulls_on_parade.sing_me_a_song()
I understand that the last two lines will call each song as a parameter in the sing_me_a_song function, but I don't get the whole 'self' thing. In song me a song you use 'self' as a parameter... which for some reason doesn't make sense to me...
And this:
def __init__(self, lyrics):
self.lyrics = lyrics
I don't even know how to comprehend it, I know it's meant to basically start the class, but I can't see what it does...
Another thing I'm having, is that looking at when I use Song("[Song lyrics]"), I'd assume there'd have to be another parameter because the class has self and lyrics in __init__... why only the lyrics?
Sorry if this was weird to understand, I don't know what I'm talking about and it makes it harder to ask for advice...
Hit up the programming thread on /g/ perhaps?
HAHAHAHAHAHAAHHAHAHAHAHAHAHAHAHA.
No.