[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Re: HELP PLEASE: sprite collision - object not iterable error



Hey I'm on my phone so I can't see the example you need help on specially, but here is some general help on the subject:
Arguments are the variables passed to a function.

Example:

def getDogYears(name, age, canine=False):
    if not canine:
        age *= 7 # age times 7
    return "%s is %s years old in dog years." % (name, age)

>> samsDogAge = getDogYears('Sam', 5)
>> print samsDogAge
>> "Sam is 35 years old in dog years."

In this case, the arguments for the function getDogYears() are:
-name
-age
-canine (optional)

So the "second argument" would be the subject's age. Also note that by using "canine=False", we have set an optional argument. This means that, if no 3rd argument is given, the function will automatically set the variable to it's assigned default value. (In this case, 'False')

Hope that helps! :)

Enargy

On Feb 21, 2012, at 9:21 PM, Scott <scott@xxxxxxxxxxxxxxx> wrote:

Thanks for your answer - Not sure what you mean by second argument?

stabbingfinger <stabbingfinger@...> writes:

Check the docs. The second argument must be an instance or subclass of Group.

Cheers.
Gumm