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
🔒Открыть пост
и посмотреть медиа
Знаете ли вы, что [[]] * 3 в Python – это три ссылки на один список, а не три списка? Удобный способ создать матрицу нулей [[0] * 3] * 3 оборачивается ловушкой: одно изменение элемента меняет сразу все строки. Причина в том, что * на последовательности повторяет ссылки, а не копирует объекты. Внутренний список создается один раз, а внешнее умножение дает три ссылки на него. Классика – матрица 3×3: matrix = [[0] * 3] * 3 matrix[0][0] = 1 print(matrix) # [[1, 0, 0], [1, 0, 0], [1, 0, 0]] – здесь изменились все строки matrix[0], matrix[1] и matrix[2] – один и тот же объект. Запись в любой из рядов видна через остальные, потому что ряд по сути один. Проверить это можно через id(): rows = [[]] * 3 print(id(rows[0]) == id(rows[1]) == id(rows[2])) # True rows[0].append("a") print(rows) # [['a'], ['a'], ['a']] – один список под тремя именами Все три элемента указывают на один и тот же пустой список. append на любом из них дописывает в этот единственный список, и изменение видно через все остальные ссылки. Правильный способ – list comprehension, который создает новый объект на каждой итерации: matrix = [[0] * 3 for _ in range(3)] matrix[0][0] = 1 print(matrix) # [[1, 0, 0], [0, 0, 0], [0, 0, 0]] – так изменилась только первая строка Внутреннее [0] * 3 тоже умножение, но там оно безопасно: нули неизменяемы, и наличие тысячи ссылок на один и тот же 0 ничего не ломает. Проблема возникает только когда * повторяет ссылку на изменяемый объект – список, словарь, set. * на последовательности экономит память, повторяя ссылки. Для неизменяемых элементов это незаметно, для изменяемых – ломает изоляцию между "копиями". Вложенные структуры безопаснее создавать через list comprehension. В следующий вторник – + и reflected operators: как Python решает чей метод звать, когда складываются объекты разных типов, и при чем тут __radd__. Код на салфетке 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