[Tutor] Side effect and return value
Albert-Jan Roskam
sjeik_appie at hotmail.com
Thu Sep 19 16:40:43 EDT 2024
Hi,
I've just read "Code that fits into your Brain".
The author says a function with a side effect should not have a return
value. But how would one write this function in order to do that? This
looks totally fine to me:
from uuid import UUID
from requests import post
def create_user(info: dict) -> UUID:
resp = post("https://some-thing/user", json=info)
resp.raise_for_status()
return UUID(resp.json()["id"])
Thanks!
AJ
More information about the Tutor
mailing list