Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <mailman.106.1710648947.3452.python-list@python.org>
Deutsch   English   Français   Italiano  
<mailman.106.1710648947.3452.python-list@python.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!fu-berlin.de!uni-berlin.de!not-for-mail
From: dn <PythonList@DancesWithMice.info>
Newsgroups: comp.lang.python
Subject: Re: Configuring an object via a dictionary
Date: Sun, 17 Mar 2024 17:15:32 +1300
Organization: DWM
Lines: 43
Message-ID: <mailman.106.1710648947.3452.python-list@python.org>
References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
 <60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
 <20240316230606.qjn5zepek645tsqq@hjp.at>
 <98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de QrY7HNbpjoIW6Gc7YAblQgi3WFbLeNfa82it7U6Nahfw==
Cancel-Lock: sha1:0rrp1slttgmAH2E/j1X91PRiVFg= sha256:pYpp/5tdg9mUcuPUp1apJrQetSHtfcZzS1mjnsjt5eo=
Return-Path: <PythonList@DancesWithMice.info>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
 reason="2048-bit key; unprotected key"
 header.d=danceswithmice.info header.i=@danceswithmice.info
 header.b=hBLvEsl6; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; 'mar': 0.07;
 'tests': 0.07; '=dn': 0.09; 'fails': 0.09;
 'from:addr:danceswithmice.info': 0.09; 'from:addr:pythonlist':
 0.09; 'values.': 0.09; 'barry': 0.16; 'hand,': 0.16; 'holzer':
 0.16; 'idiom': 0.16; 'message-id:@DancesWithMice.info': 0.16;
 'received:51.254': 0.16; 'received:51.254.211': 0.16;
 'received:51.254.211.219': 0.16; 'received:cloud': 0.16;
 'received:rangi.cloud': 0.16; 'self.name': 0.16; 'values?': 0.16;
 'wrote:': 0.16; 'problem': 0.16; 'python': 0.16; 'instead': 0.17;
 'to:addr:python-list': 0.20; "i've": 0.22; "isn't": 0.27; 'else':
 0.27; 'bit': 0.27; '>>>': 0.28; 'header:User-Agent:1': 0.30;
 'header:Organization:1': 0.31; 'checks': 0.32; 'gotten': 0.32;
 'python-list': 0.32; 'received:192.168.1': 0.32; 'but': 0.32;
 'header:In-Reply-To:1': 0.34; 'fix': 0.36; 'using': 0.37;
 'received:192.168': 0.37; 'still': 0.40; 'from:': 0.62; 'true':
 0.63; 'range': 0.64; 'received:51': 0.64; 'production': 0.71;
 'left': 0.83; 'identity,': 0.84
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 9A25134FD
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
 s=staff; t=1710648938;
 bh=MLJQwQehsmFoL5ahsYIIo+1d90LtQKcCAaQgwAduPPM=;
 h=Date:From:Subject:To:References:In-Reply-To:From;
 b=hBLvEsl6fcmFX8v1uh6dh9DjsulEcRpl076GN56FHLE9hdmZDYnZYzaX+xb+jntGp
 4faKndOwDCArxS+ZlGIOoK1acQvXCPoYPYTkPF3XGB1lucuingPTuHMWh0SO93DUC3
 ZeEmTe2xoUn//l46mRdwxiyp5bG07CxTVrlA+lDexsguAx17v5w8rqV/z+qUucHegQ
 SDpHM5qH1j6OJ22DHf/PpTlLXreWYBNKA8Oa6CQbBM9ReRVcI7jl8Je1XlqJTd19IN
 B5kHs5ca6IBV8X7fmWUUFP/YgnTOC3d5h6OFWXpjwb8JIHZEOpMO6Vj/jHc8NgPLyT
 7ey8QjWsxd6XA==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <20240316230606.qjn5zepek645tsqq@hjp.at>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
 <python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
 <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
 <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <98171cf7-c2ea-4496-8b68-fa9a8f247b3b@DancesWithMice.info>
X-Mailman-Original-References: <b169e599-e81f-45ce-8e2a-7027b59a4627@tompassin.net>
 <60E92E67-1412-4DE6-B330-495343107474@barrys-emacs.org>
 <20240316230606.qjn5zepek645tsqq@hjp.at>
Bytes: 5100



On 17/03/24 12:06, Peter J. Holzer via Python-list wrote:
> On 2024-03-16 08:15:19 +0000, Barry via Python-list wrote:
>>> On 15 Mar 2024, at 19:51, Thomas Passin via Python-list <python-list@python.org> wrote:
>>> I've always like writing using the "or" form and have never gotten bit
>>
>> I, on the other hand, had to fix a production problem that using “or” introducted.
>> I avoid this idiom because it fails on falsy values.
> 
> Perl has a // operator (pronounced "err"), which works like || (or),
> except that it tests whether the left side is defined (not None in
> Python terms) instead of truthy. This still isn't bulletproof but I've
> found it very handy.


So, if starting from:

     def method( self, name=None, ):

  rather than:

     self.name = name if name else default_value

ie

     self.name = name if name is True else default_value


the more precise:

     self.name = name if name is not None or default_value

or:

     self.name = default_value if name is None or name

because "is" checks for identity, whereas "==" and True-thy encompass a 
range of possible alternate values?

-- 
Regards,
=dn