How to detect that a function argument is the default one
Jussi Piitulainen
jpiitula at ling.helsinki.fi
Wed Dec 10 12:20:20 EST 2014
More information about the Python-list mailing list
Wed Dec 10 12:20:20 EST 2014
- Previous message (by thread): How to detect that a function argument is the default one
- Next message (by thread): How to detect that a function argument is the default one
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Jean-Michel Pichavant writes: > If you like one-liners, > > def __init__(self, center=(0,0), radius=10, mass=None): > self.center = center > self.radius = radius > self.mass = (mass is None and radius**2) or mass That's not a one-liner. That's a one-liner: def __init__(self, center=(0,0), radius=10, mass=None): self.center = center ; self.radius = radius ; self.mass = (mass is None and radius**2) or mass And as others point out, you could highlight the number of sub-expressions better by using an actual three-place expression. (Why _that_ is considered so salient, I don't know. But it is.) </deadpan>
- Previous message (by thread): How to detect that a function argument is the default one
- Next message (by thread): How to detect that a function argument is the default one
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list