Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'operator': 0.03; 'subject:How': 0.10; 'def': 0.12; 'none.': 0.16; 'subject:default': 0.16; 'ternary': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'instead.': 0.24; '>': 0.26; 'gets': 0.27; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'dec': 0.30; 'message- id:@mail.gmail.com': 0.30; 'subject:that': 0.31; 'actual': 0.34; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'received:google.com': 0.35; 'mass': 0.36; 'subject:one': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=R2ILrzbZKH11wccnt075Iz9UC1fFKNT1AflvZw81ZeQ=; b=Fg/NmJDY0mNs07+/WveBrg1d/C4rQJV9mUWI3zAtGryW/tKYI9eDJg9bwP4KbgB+QI f8Tiz2zj/2vI3thgVFKmsHGDfr5dDduykom1PFBHB1pn3A5VlYRcQC3hoGySn04vI1fP L0AGZ0LsksHBbBBwQKul6RcHgUniOTcCl7wIunqc342u7jJwxNw/4FxYgSxe1GWCg9sj AuUYlJf3Ln7kNJP561myaXyphA6mdqBig0MHyPzld7i/WT3UywVIpqidha4L+VhWbie6 c6dvGXV1ELQeHn98XM4bHAJ0PLpfjv7UXenpI7mDDR29g5OF1Ddgy4z7GNzDlwTOjyWU 3WnA== X-Received: by 10.66.220.34 with SMTP id pt2mr8487047pac.142.1418228488991; Wed, 10 Dec 2014 08:21:28 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1967177562.5434671.1418227803051.JavaMail.root@sequans.com> References: <5488634e$0$2130$426a74cc@news.free.fr> <1967177562.5434671.1418227803051.JavaMail.root@sequans.com> From: Ian Kelly Date: Wed, 10 Dec 2014 09:20:48 -0700 Subject: Re: How to detect that a function argument is the default one To: Python Content-Type: multipart/alternative; boundary=047d7b5da4f34bfa7e0509df0d32 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418228498 news.xs4all.nl 2902 [2001:888:2000:d::a6]:56456 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82295 --047d7b5da4f34bfa7e0509df0d32 Content-Type: text/plain; charset=UTF-8 On Wed, Dec 10, 2014 at 9:10 AM, Jean-Michel Pichavant < jeanmichel@sequans.com> wrote: > 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 If mass is None and radius is 0, then self.mass gets set to None. Use the actual ternary operator instead. --047d7b5da4f34bfa7e0509df0d32 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Wed, Dec 10, 2014 at 9:10 AM, Jean-Michel Pichavant <= ;jeanmichel@sequans.com> w= rote:
> If you like one-liners,
>
> def __init__(self, ce= nter=3D(0,0), radius=3D10, mass=3DNone):
> =C2=A0 =C2=A0 self.center = =3D center
> =C2=A0 =C2=A0 self.radius =3D radius
> =C2=A0 =C2= =A0 self.mass =3D (mass is None and radius**2) or mass

If mass = is None and radius is 0, then self.mass gets set to None. Use the actual te= rnary operator instead.
--047d7b5da4f34bfa7e0509df0d32--