返回顶部

收藏

Check if a default parameter value being used

更多
def saver(x=None):
     if x is None:         # no argument passed?
         x = []            # run code to make a new list
     x.append(1)           # changes new list object
     print x

saver([2])

saver()                   # doesn't grow here

saver()

标签:Python,Function

收藏

0人收藏

支持

0

反对

0

发表评论