Python пытается понять, что такое MyClass, но его еще нет:
def func(x: MyClass) -> None: # Ошибка: MyClass еще не определен ...
class MyClass: ...
from __future__ import annotations делает так, что все аннотации типов воспринимаются как строки. Это позволяет использовать поздние ссылки (на классы, которые еще не объявлены) — User.
То есть Python не будет сразу требовать, чтобы MyClass уже был определен. Он просто запомнит строку MyClass и разберется с этим позже, когда все классы уже будут объявлены.
Python пытается понять, что такое MyClass, но его еще нет:
def func(x: MyClass) -> None: # Ошибка: MyClass еще не определен ...
class MyClass: ...
from __future__ import annotations делает так, что все аннотации типов воспринимаются как строки. Это позволяет использовать поздние ссылки (на классы, которые еще не объявлены) — User.
То есть Python не будет сразу требовать, чтобы MyClass уже был определен. Он просто запомнит строку MyClass и разберется с этим позже, когда все классы уже будут объявлены.
BY Python: задачки и вопросы
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
A leaked Telegram discussion by 50 so-called crypto influencers has exposed the extraordinary steps they take in order to profit on the back off unsuspecting defi investors. According to a leaked screenshot of the chat, an elaborate plan to defraud defi investors using the worthless “$Few” tokens had been hatched. $Few tokens would be airdropped to some of the influencers who in turn promoted these to unsuspecting followers on Twitter.
Telegram announces Anonymous Admins
The cloud-based messaging platform is also adding Anonymous Group Admins feature. As per Telegram, this feature is being introduced for safer protests. As per the Telegram blog post, users can “Toggle Remain Anonymous in Admin rights to enable Batman mode. The anonymized admin will be hidden in the list of group members, and their messages in the chat will be signed with the group name, similar to channel posts.”