## 4.8 Parameter default values 

Default values for parameters can be any of a number of values. At their simplest, they can be string, int, or float literals: 

foo: str = "abc" bar: int = 123 bat: float = 45.6 

They can also use any of Python’s built-in constants: 

yep: bool = True nope: bool = False nada: object = None 

There’s also special support for a default value of NULL , and for simple expressions, documented in the following sections. 

## 4.9 The NULL default value 

For string and object parameters, you can set them to None to indicate that there’s no default. However, that means the C variable will be initialized to$_{Py_None}$. For convenience’s sakes, there’s a special value called$_{NULL}$ for just this reason: from Python’s perspective it behaves like a default value of$_{None}$ , but the C variable is initialized with NULL . 

## 4.10 Expressions specified as default values 

The default value for a parameter can be more than just a literal value. It can be an entire expression, using math operators and looking up attributes on objects. However, this support isn’t exactly simple, because of some non- obvious semantics. 

Consider the following example: 

foo: Py_ssize_t = sys.maxsize - 1 

$_{sys.maxsize}$can have different values on different platforms. Therefore Argument Clinic can’t simply evaluate that expression locally and hard-code it in C. So it stores the default in such a way that it will get evaluated at runtime, when the user asks for the function’s signature. 

What namespace is available when the expression is evaluated? It’s evaluated in the context of the module the builtin came from. So, if your module has an attribute called “$_{max_widgets}$ ”, you may simply use it: 

foo: Py_ssize_t = max_widgets 

If the symbol isn’t found in the current module, it fails over to looking in$_{sys.modules}$ . That’s how it can find $_{sys.maxsize}$for example. (Since you don’t know in advance what modules the user will load into their interpreter, it’s best to restrict yourself to modules that are preloaded by Python itself.) 

Evaluating default values only at runtime means Argument Clinic can’t compute the correct equivalent C default value. So you need to tell it explicitly. When you use an expression, you must also specify the equivalent expression in C, using the$_{c_default}$ parameter to the converter: 

foo: Py_ssize_t(c_default="PY_SSIZE_T_MAX - 1") = sys.maxsize - 1 

Another complication: Argument Clinic can’t know in advance whether or not the expression you supply is valid. It parses it to make sure it looks legal, but it can’t actually know. You must be very careful when using expressions to specify values that are guaranteed to be valid at runtime! 

Finally, because expressions must be representable as static C values, there are many restrictions on legal expressions. Here’s a list of Python features you’re not permitted to use: 

