PYHINTS Telegram 59
توی این مثال (قطعا غیر واقعی)
هر ۲ تا روش رو بررسی کردیم و البته قانون
exception
هم رعایت شده.
تفاوت سرعت رو خودتون می‌بینید دلیلش هم اینه که اسم تابع رو وقتی کاربر می‌بینه توی ۹۹٪ موارد قطعا متوجه هست که ۲ تا عدد باید بده و ...
توی
LBYL
حتی اگر همه چیز درست باشه کد باید شرط‌ها رو چک کنه و این زمان رو کند می‌کنه تا خروجی بده
EAFP
سعی می‌کنه خروجی رو سریعا محاسبه کنه ۱٪ اگر به exception بخوره handler مربوط به اون نوع exception رو اجرا می‌کنه و این یعنی سربار کمتر

تمیزی کد هم که قطعا EAFP بسیار بسیار پایتونی تر هست.

@PyHints
👍262👏1



tgoop.com/pyHints/59
Create:
Last Update:

توی این مثال (قطعا غیر واقعی)
هر ۲ تا روش رو بررسی کردیم و البته قانون
exception
هم رعایت شده.
تفاوت سرعت رو خودتون می‌بینید دلیلش هم اینه که اسم تابع رو وقتی کاربر می‌بینه توی ۹۹٪ موارد قطعا متوجه هست که ۲ تا عدد باید بده و ...
توی
LBYL
حتی اگر همه چیز درست باشه کد باید شرط‌ها رو چک کنه و این زمان رو کند می‌کنه تا خروجی بده
EAFP
سعی می‌کنه خروجی رو سریعا محاسبه کنه ۱٪ اگر به exception بخوره handler مربوط به اون نوع exception رو اجرا می‌کنه و این یعنی سربار کمتر

تمیزی کد هم که قطعا EAFP بسیار بسیار پایتونی تر هست.

@PyHints

BY Python Hints




Share with your friend now:
tgoop.com/pyHints/59

View MORE
Open in Telegram


Telegram News

Date: |

How to Create a Private or Public Channel on Telegram? The court said the defendant had also incited people to commit public nuisance, with messages calling on them to take part in rallies and demonstrations including at Hong Kong International Airport, to block roads and to paralyse the public transportation system. Various forms of protest promoted on the messaging platform included general strikes, lunchtime protests and silent sit-ins. The initiatives announced by Perekopsky include monitoring the content in groups. According to the executive, posts identified as lacking context or as containing false information will be flagged as a potential source of disinformation. The content is then forwarded to Telegram's fact-checking channels for analysis and subsequent publication of verified information. In 2018, Telegram’s audience reached 200 million people, with 500,000 new users joining the messenger every day. It was launched for iOS on 14 August 2013 and Android on 20 October 2013. Find your optimal posting schedule and stick to it. The peak posting times include 8 am, 6 pm, and 8 pm on social media. Try to publish serious stuff in the morning and leave less demanding content later in the day.
from us


Telegram Python Hints
FROM American