Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82302

Re: How to detect that a function argument is the default one

From Jussi Piitulainen <jpiitula@ling.helsinki.fi>
Newsgroups comp.lang.python
Subject Re: How to detect that a function argument is the default one
Date 2014-12-10 19:20 +0200
Organization A noiseless patient Spider
Message-ID <qotmw6vxvzf.fsf@ruuvi.it.helsinki.fi> (permalink)
References <mailman.16813.1418227811.18130.python-list@python.org>

Show all headers | View raw


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>

Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: How to detect that a function argument is the default one Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-12-10 17:10 +0100
  Re: How to detect that a function argument is the default one Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-12-10 19:20 +0200

csiph-web