English
Open in Telegram

Thread >>> class A(object):

6 messages · –
A
>>> class A(object): ... def init(self, a): ... self._a = a ... ... (at)property ... def a(self): ... return self._a ... >>> a = A('test') >>> a.a 'test' >>> a.a = 'pleh' Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: can't set attribute
  1. A
    این یک پروپرتی read only هست. ولی نمیدونم دقیقا چطور کار میکنه، اگر دوستان کسی میدونه لطفا توضیح بده
  2. S
    دکوراتور property فقط برای ساختن getter هست. شما میخواین setter هم داشته باشه باید یه متد دیگه به این شکل هم اضافه کنین به کلاس: (at)foo.setter def foo(self, x): self._a = x
PPython + Linux ExpertsPython + Linux Experts@PythonLinuxExperts · group · Tech
4 287members21writing in 30 days
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · Index limits · Remove a page · Catalog · Search · How we count