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: |

In 2018, Telegram’s audience reached 200 million people, with 500,000 new users joining the messenger every day. It was launched for iOS on 14 August 2013 and Android on 20 October 2013. Telegram has announced a number of measures aiming to tackle the spread of disinformation through its platform in Brazil. These features are part of an agreement between the platform and the country's authorities ahead of the elections in October. Matt Hussey, editorial director at NEAR Protocol also responded to this news with “#meIRL”. Just as you search “Bear Market Screaming” in Telegram, you will see a Pepe frog yelling as the group’s featured image. How to create a business channel on Telegram? (Tutorial) As the broader market downturn continues, yelling online has become the crypto trader’s latest coping mechanism after the rise of Goblintown Ethereum NFTs at the end of May and beginning of June, where holders made incoherent groaning sounds and role-played as urine-loving goblin creatures in late-night Twitter Spaces.
from us


Telegram Python Hints
FROM American