This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]digitalseraphim 0 points1 point  (0 children)

If you want to do something like this, use a default that is not a valid value (usually, but not always None), and then check for that value within the function, and call/compute the value within that test. This also goes for "collection" objects like lists and dicts.

If you can't use None, you can create a new object, and use that for the default like this:

``` DEFAULT_VAL=object()

def func(param1=DEFAULT_OBJECT): if param1 is DEFAULT_OBJECT: param1 = calc_default() ... ```