Telegram Group & Telegram Channel
افزودن توضیحات (annotations) به توابع در پایتون

هنگامی که یک تابع جدید در پایتون تعریف می کنیم، می توانیم در خصوص پارامترهای ورودی و خود تابع توضیحاتی را اضافه کنیم. این کار علی الخصوص برای زمانی که به صورت گروهی مشغول برنامه نویسی هستیم بسیار کارآمد است.
برای افزودن توضیحات به پارامترها از علامت کالن (:) و برای افزودن توضیح به خود تابع در خصوص مقدار بازگشتی آن از علامت (<-) استفاده می کنیم.
نمونه هایی از annotation ها در تصویر این پست نشان داده شده است. یادآوری می کنم که annotation ها صرفا از جنس توضیحات هستند و تاثیری در روال اجرا برنامه ندارند.
در تصویر این پست، چهار تابع برای نمایش شیوه کار annotationها تعریف شده است.
برای مشاهده annotationهای تعریف شده می توانید از متد annotations بعد از نام تابع استفاده می کنیم. مثلا در مثال ما print(sum_numbers4.annotations)

#آموزش_پایتون
#پایتون_مالی
#توضیحات
#تابع
#annotations


@python4finance



tg-me.com/python4finance/538
Create:
Last Update:

افزودن توضیحات (annotations) به توابع در پایتون

هنگامی که یک تابع جدید در پایتون تعریف می کنیم، می توانیم در خصوص پارامترهای ورودی و خود تابع توضیحاتی را اضافه کنیم. این کار علی الخصوص برای زمانی که به صورت گروهی مشغول برنامه نویسی هستیم بسیار کارآمد است.
برای افزودن توضیحات به پارامترها از علامت کالن (:) و برای افزودن توضیح به خود تابع در خصوص مقدار بازگشتی آن از علامت (<-) استفاده می کنیم.
نمونه هایی از annotation ها در تصویر این پست نشان داده شده است. یادآوری می کنم که annotation ها صرفا از جنس توضیحات هستند و تاثیری در روال اجرا برنامه ندارند.
در تصویر این پست، چهار تابع برای نمایش شیوه کار annotationها تعریف شده است.
برای مشاهده annotationهای تعریف شده می توانید از متد annotations بعد از نام تابع استفاده می کنیم. مثلا در مثال ما print(sum_numbers4.annotations)

#آموزش_پایتون
#پایتون_مالی
#توضیحات
#تابع
#annotations


@python4finance

BY Python4Finance




Share with your friend now:
tg-me.com/python4finance/538

View MORE
Open in Telegram


Python4Finance Telegram | DID YOU KNOW?

Date: |

Telegram auto-delete message, expiring invites, and more

elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.

Python4Finance from tw


Telegram Python4Finance
FROM USA