[issue44365] Bad dataclass post-init example

Eric V. Smith report at bugs.python.org
Thu Jun 17 08:22:06 EDT 2021


Eric V. Smith <eric at trueblade.com> added the comment:

I was thinking about something like:

@dataclass
class FtpHelper(ftplib.FTP):
    my_host: str
    my_user: str
    lookup_password: InitVar[Callable]

    def __post_init__(self, lookup_password):
        super().__init__(host=self.my_host, user=self.my_user, passwd=lookup_password())

def get_password():
    return "a password"

ftp = FtpHelper(hostname, username, get_password)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44365>
_______________________________________


More information about the Python-bugs-list mailing list