Can I do this in the method definition
No. During the method definition there's no way to know what value x
might have at run-time. Default arguments are evaluated once at definition time, there's no way to save a dynamic value for y
.
or should I do something like resize(x,y=None)
and check inside
exactly. This is a common idiom in Python.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…