neil
neil

Reputation: 203

learn python the hard way exercise 18 help

i understand all the functions except the first one. whats the (*args) mean?

thanks

def print_twice(*args):
    arg1, arg2 = args
    print 'arg1: %r arg2: %r' % (arg1, arg2)

def print_twice_again(arg1, arg2):
    print 'arg1: %r arg2: %r' % (arg1, arg2)

def print_once(arg1):
    print 'arg1: %r' % arg1

def print_none():
    print 'i got nothin...'

print_twice("neil", "harper")
print_twice_again("neil", "harper")
print_once("first!")
print_none()

Upvotes: 4

Views: 837

Answers (1)

Jaroslav Jandek
Jaroslav Jandek

Reputation: 9563

One asterix specifies a list, two asterixes specify a dictionary.

Upvotes: 5

Related Questions