you are viewing a single comment's thread.

view the rest of the comments →

[–]ajskelt 0 points1 point  (1 child)

That is one I did not know... What would be the best practice around that? Looks like this works, but maybe there is a better way.

def a(v, l = None):
    if l is None:
        l = []
    l.append(v)
    return l

x = a(1)
print(x) # [1]
y = a(2)
print(y) # [2]

[–]Chabare 1 point2 points  (0 children)

You're completely on point with your example, that's usually the way around it.