+16
−0
Loading
You need the Bankleitzahl (which we get from the IBAN), user name and password (which the FinTS standard calls PIN), the URL and the product id to create a client. ## Why `@contextmanager`? The Python `fints` library (https://python-fints.readthedocs.io/en/latest/quickstart.html) then suggests a construct like: ``` client = FinTS3PinTanClient(...) with client: foo(client) ``` I personally want to use it like this in my code: ``` with bank_account._fints_client(...) as client: foo(client) ``` To allow the `as` construction (see https://docs.python.org/3/reference/compound_stmts.html#with), the bank_account._fints_client(...).__enter__() needs to return the client object. I didn't want to create a throwaway object for that, but luckily, the @contextmanager decorator does exactly that. Once the user of my library exits their `with bank_account._fints_client(...) as client:` context, the code returns to the line after my "yield client", which will then close the "with client" context, which will correctly close the client object as the fints library authors intended.