Side effect and return value
Albert-Jan Roskam <[email protected]> Thu, 19 Sep 2024 22:40:43 +0200
| Newsgroups | gmane.comp.python.tutor |
|---|---|
| Message-ID | <DB9PR10MB66896E3A843D1232560182A683632@DB9PR10MB6689.EURPRD10.PROD.OUTLOOK.COM> |
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
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor