Pokémon X and Y Fan Community
April 18, 2024, 06:51:50 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
  Home Help Search Arcade Gallery SHOUTBOX Staff List Calendar Members Login Register  

Programming Thread

Pages: 1 ... 8 9 [10] 11 12
  Send this topic  |  Print  
Author Topic: Programming Thread  (Read 3495 times)
0 Members and 3 Guests are viewing this topic.
klondikebar
Global Moderator
Malevolent Murkrow
*****

Level: 44
Offline Offline

Posts: 2977


View Profile
Badges: (View All)
« Reply #135 on: May 16, 2013, 01:46:35 am »

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 Cheesy

Alright Cheesy

Well, this example from learn python the hard way:

Code:
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:
Code:
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.
Report Spam   Logged
Pages: 1 ... 8 9 [10] 11 12
  Send this topic  |  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
Free SMF Hosting - Create your own Forum

Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy
Page created in 0.057 seconds with 21 queries.