PYHINTS Telegram 319
من راجب repr, str , ... صحبت کردم.
این کد رو یکی از اعضا فرستاده (درحال code review این کد رو دیده)

@dataclass
class CasbinRuleEntity:
id: typing.Optional[int] = None
ptype: typing.Optional[str] = None
v0: typing.Optional[str] = None
v1: typing.Optional[str] = None
v2: typing.Optional[str] = None
v3: typing.Optional[str] = None
v4: typing.Optional[str] = None
v5: typing.Optional[str] = None

def __str__(self):
arr = [self.ptype]
for v in (self.v0, self.v1, self.v2, self.v3, self.v4, self.v5):
if v is None:
break
arr.append(v)
return ', '.join(arr)

def __repr__(self):
return '<CasbinRule {}: "{}">'.format(self.id, str(self))
ی مورد رو من بگم و بعد سکوت کنم :
یکی از دلایلی که
@dataclass
رو استفاده می‌کنیم این هست که دیگه repr بدرد نخور ننویسیم.

باقی مشکلات رو شما بگید (به اکثر موارد قبلاً اشاره شده توی کانال)
🤔14👍92🍓21👎1🔥1😱1🆒1



tgoop.com/pyHints/319
Create:
Last Update:

من راجب repr, str , ... صحبت کردم.
این کد رو یکی از اعضا فرستاده (درحال code review این کد رو دیده)

@dataclass
class CasbinRuleEntity:
id: typing.Optional[int] = None
ptype: typing.Optional[str] = None
v0: typing.Optional[str] = None
v1: typing.Optional[str] = None
v2: typing.Optional[str] = None
v3: typing.Optional[str] = None
v4: typing.Optional[str] = None
v5: typing.Optional[str] = None

def __str__(self):
arr = [self.ptype]
for v in (self.v0, self.v1, self.v2, self.v3, self.v4, self.v5):
if v is None:
break
arr.append(v)
return ', '.join(arr)

def __repr__(self):
return '<CasbinRule {}: "{}">'.format(self.id, str(self))
ی مورد رو من بگم و بعد سکوت کنم :
یکی از دلایلی که
@dataclass
رو استفاده می‌کنیم این هست که دیگه repr بدرد نخور ننویسیم.

باقی مشکلات رو شما بگید (به اکثر موارد قبلاً اشاره شده توی کانال)

BY Python Hints


Share with your friend now:
tgoop.com/pyHints/319

View MORE
Open in Telegram


Telegram News

Date: |

Avoid compound hashtags that consist of several words. If you have a hashtag like #marketingnewsinusa, split it into smaller hashtags: “#marketing, #news, #usa. Just at this time, Bitcoin and the broader crypto market have dropped to new 2022 lows. The Bitcoin price has tanked 10 percent dropping to $20,000. On the other hand, the altcoin space is witnessing even more brutal correction. Bitcoin has dropped nearly 60 percent year-to-date and more than 70 percent since its all-time high in November 2021. The Standard Channel The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he “allowed them to exist.” The visual aspect of channels is very critical. In fact, design is the first thing that a potential subscriber pays attention to, even though unconsciously.
from us


Telegram Python Hints
FROM American