1

A function in Python:

def f(a=1):
  print(a)

What easiest way to detect whether the argument «a» is actually passed to f or is missed?

There is a function «IsMissing» in VBA:

IsMissing(argname)

Does anything similar exist in Python?


I mean something like this:

def f(a=1):
  …
  …


f()
>>> The argument «a» was not passed!
f(1)
>>> The argument «a» was passed and is equal to: 1
  • You can tell if something other than `1` was passed by checking the value. There is no way to distinguish between explicitly passing the default value and and getting it "by default" when it is not passed. – BrenBarn Dec 27 '14 at 22:23

0 Answers0