TGViewer
Python Community Python Community @python_community_ru · 11.6K subscribers
Post #1685 3.56K
☝️ Что означает self в классе?

👉 Self ссылается на экземпляр класса. Так метод может обновлять объект, к которому принадлежит.

Ниже передача self в init() дает возможность установить цвет экземпляра при инициализации:

class Shirt:
def __init__(self, color):
self.color = color

s = Shirt('yellow')
s.color
#=> 'yellow'

Python Community
More from @python_community_ru
  1. Oct 9, 2026‍Вышел Python 3.15: ленивые импорты, frozendict, UTF-8 по умолчанию и JIT, который наконец…
  2. Oct 8, 2026🦙 Ollaya: запуск моделей принятия решений в стиле Ollama. Скачиваете модель, поднимаете л…
  3. Oct 7, 2026‍Python 3.15 почти готов: вышел RC3, финальный релиз 9 октября Python 3.15.0rc3 вышел 2 ок…
  4. Oct 6, 2026🐍 Python Workers в Cloudflare вышли в GA Cloudflare официально сделала Python полноценным…
  5. Oct 5, 2026‍🖥 Python-дайджест недели: PyPy 8 с Python 3.12, отладка None и фреймворки для агентов Py…
  6. Oct 4, 2026🐍 Python тормозит? В 3.15 добавили инструмент, который покажет где Tachyon (`profiling.sa…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →