Is it allowed to use function results as default arguments ?

Terry Reedy tjreedy at
Wed Jul 30 11:14:28 EDT 2008

fred.haab wrote:
> Well, others have answered the question, but I thought I'd throw in
> that it would be more pythonic to do something like:
> def Get_Relative_Path(target, base = None):
>     if base is None:
>         base = os.curdir
>     ...

Since os.curdir is a constant, this is nonesensical.  One only needs the 
dummy default when one wants an expression re-evaluated with each call.

More information about the Python-list mailing list