From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,NO_DNS_FOR_FROM, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from [10.7.7.5] (unknown [182.253.183.89]) by gnuweeb.org (Postfix) with ESMTPSA id C126681892; Tue, 20 Dec 2022 00:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671497155; bh=Hs23MkCKz5jMpfPcLXE3toMSXh7C93UzjV7RlKyq5yc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=IDdnL5D8MGKm1zhmhWz+ztcIw3d1FrxBwtsZF1o9Qbz1xApmdQezQ88jRANT0KR5v WKTUborCmfc+X8wKn4PRQ9c90pHkA4vv3k+xjpSWzwtOs52QGd7nqvgUKM/B/8W0VP o90xhqsHuxmvHHf+nGSaz6/uIDC7KxKzrjBWApsZXqJv/lHmLdeIwaGXX96i4p0DOX sIF6bvTcNRBqNvv4H1UZDJmUybgo6xsdMJ90N7aXRBPRgLq/7AeAQQYaneunEjBP/5 ckIyy/L7zpEgAjRFFAc0m0gNmp8kw3zX1pDl3z5+8fx3rEqGkPunfjuEPVgXwKGUP7 pjy2aTrppsqew== Message-ID: Date: Tue, 20 Dec 2022 07:45:50 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v3 04/17] fix: utils: Fix the extract_list() utility function To: Alviro Iskandar Setiawan , Muhammad Rizki Cc: GNU/Weeb Mailing List References: <20221219235721.126-1-kiizuha@gnuweeb.org> <20221219235721.126-5-kiizuha@gnuweeb.org> Content-Language: en-US From: Ammar Faizi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: On 12/20/22 7:33 AM, Alviro Iskandar Setiawan wrote: > On Tue, Dec 20, 2022 at 6:57 AM Muhammad Rizki wrote: >> +def extract_list(key: str, thread: Message): >> + try: >> + people = thread.get(key.lower()) >> + if not people: >> + return [] >> + except: >> return [] >> return __extract_list(people) > > Why does this have to be a "try and except"? > And not something like: > > k = key.lower() > if k in thread: > return __extract_list(people) > return [] I don't know much about Python, but doesn't that only work for dict? Or it can use `in` operator too? `thread` is an instance of Message class object here. -- Ammar Faizi