How python implements the default parameters of a function
This article will explain in detail how python implements the default parameters of the function. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Default parameters of the function
> def foo (x = []): X.append (1)... Print x. > foo () [1] > foo () [1,1]
A safer approach is to:
Def foo (x=None):... If x is None:... X = []. X.append (1)... Print x. > > foo () [1] > > foo () [1] > > on "how to achieve the default parameters of python function" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.