PYTHONLEARNME Telegram 201
من راجب 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 بدرد نخور ننویسیم.

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



tgoop.com/pythonlearnme/201
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 🧑‍💻PythonDev🧑‍💻


Share with your friend now:
tgoop.com/pythonlearnme/201

View MORE
Open in Telegram


Telegram News

Date: |

Joined by Telegram's representative in Brazil, Alan Campos, Perekopsky noted the platform was unable to cater to some of the TSE requests due to the company's operational setup. But Perekopsky added that these requests could be studied for future implementation. Hashtags 3How to create a Telegram channel? 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)
from us


Telegram 🧑‍💻PythonDev🧑‍💻
FROM American