Jump to content

  • Log In with Google      Sign In   
  • Create Account


Lysy

Member Since 09 Mar 2013
Offline Last Active Yesterday, 01:05 PM

Posts I've Made

In Topic: What happen if "self" in second argument

21 September 2014 - 04:42 AM

Yeah,i am pretty familiar with OOP smile.png ,i know what self do in first argument but not in the second argument,thank you

 Oh sorry, your first post was hard to understand.

self.tilemap.update(dt / 1000., self)

tilemap.update() takes 3 arguments, self(i.e tilemap), dt, and game. Second self indicates to 'game' instance, which tilemap is a member of. And since we're in scope of game class. we pass it as 'self'.


In Topic: What happen if "self" in second argument

20 September 2014 - 06:15 AM

Hello there.

 

Quick question: are you familiar with OOP?

 

'self.' is just a pythonic way of saying member of a class, or more like an instance of a class

 

Really quick comparison:

class jedi
{
public:
    int force;
    double lightsaber;
};
class jedi(object):
    def __init__(self):
        self.force = 0
        self.lightsaber = 0

In both cases force and lightsaber are class members, each instance of jedi will have their own force and lightsaber.

 

edit:

and python is designed that you need to pass 'self' (class instance) to its method among other arguments.


In Topic: Can you explain to me this code !

19 September 2014 - 03:06 PM

when you type 100

it will check  if the number has 1 or 0

1. The script works fine, deal with it.

2. Try using 'print' on every variable that you're not sure on what value it is.

3. Your posts will keep getting downvoted as long as they doesn't contain any useful information/doesn't improve the discussion, etc. In simple words: you're spamming.

 

I'm done. good luck with your learning.


In Topic: Can you explain to me this code !

19 September 2014 - 03:31 AM

Lysy i read the code!!

ok i need answer for this question to be sure !

Try to type 100 you will get 
You greedy bastard! Good job!
that's mean 
else:
dead("You greedy bastard!")
& i should get that 
if "0" in choice or "1" in choice:
how_much = int(choice)

 

Sorry for hard understanding

Thanks

Yes, this is correct, why you need to ask such a trivial question, when you can just run the code to be sure. It seems futile trying to help you out.


In Topic: Can you explain to me this code !

18 September 2014 - 02:15 PM

 

55 isn't less than 50 so when we don't get dead("You greedy bastard!")

def dead(why):
    print why, "Good job!"
    exit(0)

exit(0) ends up a script.

 

Please, read code first, google/bing it later.


PARTNERS