Why this unpacking of arguments does not work?

The ** syntax requires a mapping (such as a dictionary); each key-value pair in the mapping becomes a keyword argument.

Your generate() function, on the other hand, returns a tuple, not a dictionary. You can pass in a tuple as separate arguments with similar syntax, using just one asterisk:

create_character = player.Create(*generate_player.generate())

Alternatively, fix your generate() function to return a dictionary:

def generate():
    print "Name:"
    name = prompt.get_name()
    print "Age:"
    age = prompt.get_age()
    print "Gender M/F:"
    gender = prompt.get_gender()

    return {'name': name, 'age': age, 'gender': gender}

Leave a Comment