Hello
Here is what I would like to implement
class Circle:
def __init__(center=(0,0), radius=10, mass=1)):
self.center = center
self.radius = radius
if "mass is the default one": <-----
self.mass = radius**2
else:
self.mass = mass
I cant just test if mass == 1: because if I call
C1 = Circle((0,0), 7, 1)
then in that case I want: self.mass = 1
If i call C2 = Circle((6,8), 8)
then in that case I want: self.mass = radius**2
I have the idea to write:
def __init__(center=(0,0), radius=10, mass=None)):
if mass == None:
self.mass = radius**2
else:
self.mass = mass
but maybe Python provides something clever.
Thx
--
https://mail.python.org/mailman/listinfo/python-list