Logo
TGCATALOG
Catalog Collections Blog
Code on a Napkin - Python coding

Code on a Napkin - Python coding

Channel about programming in Python and other languages. Simple explanations and codes.

No ratings
319
28.10.2026
319
28.10.2026
No ratings
319
28.10.2026
Safe redirect via bot
О канале

Channel about programming in Python and other languages. Simple explanations and codes.

Подписчиков 2,347
Тематика Technology
Язык English
Ссылка t.me/napkincode

We also recommend

Kekaton AI | Voiceover and voice clone
Kekaton AI | Voiceover and voice clone
Bot

AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.

Description

Resource for those interested in programming. Focus on Python, but covers other topics as well. Simple examples and breakdowns.

Latest posts

Code on a Napkin - Python coding
Code on a Napkin - Python coding
🔒Открыть пост
и посмотреть медиа
Знаете ли вы, что a + b и b + a в Python могут вернуть разное? Сложение выглядит симметрично, но под капотом Python сначала вызовет type(a).__add__(a, b). Левый и правый операнды идут через разные методы – __add__ и __radd__. Если у __add__ левого типа нет реализации для типа правого – он вернет NotImplemented, и Python вызовет __radd__ правого. class Money: def __init__(self, n): self.n = n def __radd__(self, other): return Money(self.n + other) result = 10 + Money(5) print(result.n) # 15 int.__add__(10, Money(5)) возвращает NotImplemented – тип int ничего не знает о Money. Тогда Python вызывает Money.__radd__(Money(5), 10) – и он-то знает что делать с int. Важно: NotImplemented это значение-синглтон, не исключение NotImplementedError. Возврат NotImplemented – сигнал для того чтобы попробовать другой метод, а не ошибка. Бывает исключение из обычного порядка: если правый операнд – подкласс левого и определяет свой __radd__, он вызывается первым, до __add__ левого: class A: def __add__(self, other): return "A.__add__" class B(A): def __radd__(self, other): return "B.__radd__" print(A() + B()) # B.__radd__ – а не A.__add__ Это сделано чтобы подкласс мог переопределить поведение базового класса. Если бы порядок был как обычно, то A.__add__ отработал бы первым и B никогда бы не получил шанс вмешаться, даже специально определив __radd__. Если оба метода возвращают NotImplemented (или их вообще нет) – случится TypeError: class X: pass class Y: pass try: X() + Y() except TypeError as e: print(e) # unsupported operand type(s) for +: 'X' and 'Y' Именно это сообщение Python выдает когда исчерпаны все варианты диспетчеризации. + может попробовать сделать сложение в два захода. Сначала через левый объект. И если через левый не получилось – то через правый. NotImplemented здесь – способ сказать "передай дальше", а не ошибка. Те же правила распространяются на __rsub__, __rmul__, __rtruediv__ и остальные reflected-методы. В следующий вторник – / vs // и отрицательное деление: почему -7 // 2 == -4, а не -3. Код на салфетке x Кусочки кода
Code on a Napkin - Python coding
FAQ

Open Code on a Napkin - Python coding in Telegram and press the Start button. No separate registration is required.

Yes. The service is designed to be straightforward: open the resource, follow the on-screen instructions and start using it.

No. You can use Code on a Napkin - Python coding directly in Telegram unless the resource description says otherwise.

Access depends on the resource. Check the current information in Telegram after opening Code on a Napkin - Python coding.

The exact features depend on the resource. Open Code on a Napkin - Python coding to see its current functions, content and access conditions.
Subscriber dynamics
+-0.4% last 30 days
Current
2,347
Month ago
2,356
Average growth
+0 / day
Updated
1 day ago

Reviews for channel Code on a Napkin - Python coding

Log in to leave a review

Only registered users can share their opinion.

No reviews yet

Be the first to share your impression of this resource!

Similar resources

Loading
Switch to Light Theme
Home Catalog Collections Blog Login