I am a fairly good programmer. So, when I see a problem, my natural tendency is to code.
I’m trying to break that pattern. Instead, I ask ChatGPT.
Write a compact 1-line Python expression that checks if
user.id
ends with @gramener.com or @straive.com
user.id.endswith(('@gramener.com', '@straive.com'))
After 15 years of using Python, I learnt that .endswith()
supports tuple suffixes. This has been around since Python 2.5 (released in 2006 — before I knew Python.) The documentation has a tiny sentence in the middle saying “suffix can also be a tuple of suffixes to look for.”
I checked with a few colleagues, including Jaidev. They didn’t know it either.
It’s small little things like this that made me conclude.
I’m not going to code anymore. ChatGPT will, instead.