首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

Python中亟需留心的

2012-08-27 
Python中需要留心的Important warning: The default value is evaluated only once. This makes a differe

Python中需要留心的
Important warning: The default value is evaluated only once. This makes a difference when the default is a mutable object such as a list, dictionary, or instances of most classes. For example, the following function accumulates the arguments passed to it on subsequent calls:

def f(a, L=None):    if L is None:        L = []    L.append(a)    return L

热点排行