Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 21 lines (15 sloc) 0.705 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/usr/bin/env python3

# -------------------
# FunctionKeywords.py
# -------------------

print("FunctionKeywords.py")

def f (x, y, z) :
    return [x, y, z]

assert f(2, 3, 4) == [2, 3, 4]
#f(2, 3) # TypeError: f() takes exactly 3 arguments (2 given)
#f(2, 3, 4, 5) # TypeError: f() takes exactly 3 arguments (4 given)

assert f(2, z = 4, y = 3) == [2, 3, 4]
#f(z = 4, 3, x = 2) # SyntaxError: non-keyword arg after keyword arg
#f(2, z = 4, x = 2) # TypeError: f() got multiple values for keyword argument 'x'
#f(2, z = 4, a = 5) # TypeError: f() got an unexpected keyword argument 'a'

print("Done.")
Something went wrong with that request. Please try again.