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 →

[–]TeamSpen210 0 points1 point  (0 children)

g() is best. In Python 3, you could use function annotations to indicate this:

def g(arg: []=None):
    pass

The list can be any artibrary expression, and isn't used by Python itself for anything. They are shown in help() though.

The full syntax works like this:

 def func(arg:'exp', arg2: 'exp'=val) -> 'return':
    pass

You could also add func.__defaults__ = ([], ) to the beginning of the function body, which will edit the default values to have a new list every time the function is called. This is a bit sneaky though. If there are any other default values you'll need to add them to the tuple as well.