News for hackers. Stuff that matters.
Re:Why does `True == False is False` evaluate to False in Py... by collyw on Saturday May 02, 2020 @08:59AM (#23051498)
This. I got asked an interview question that involved writing two list comprehensions in python in an interview. The guy then asked if I could do the same without the intermediate variable - basically nesting them. I had a mental block for a bit before I realised how simple the task was. It just that I would never think to nest list comprehensions because I find it horribly unreadble.
Re:Why does `True == False is False` evaluate to False in Py... by kwhitefoot on Saturday May 02, 2020 @12:29PM (#23052773)
> if I could do the same without the intermediate variable

I'm glad I never had to go through such ridiculous hoops to get a job.

If I had I might have been inclined to say "Yes I could but I wouldn't do it because it would be unmaintainable."

Real application programming isn't about being concise it's about being cost effective. Sometimes conciseness achieves that end often it does not. Having a well named intermediate variable can help document what is happening so that the poor sod who has to fix a bug in or extend your code two years later doesn't have to spend an hour deciphering your code to apply a two minute fix. That poor sod might be the very same person who wrote it.

Re:Why does `True == False is False` evaluate to False in Py... by rohan1024 on Saturday May 02, 2020 @10:10AM (#23051874)
I was a Java developer for more than 4 years at the beginning of my career. I was more of application developer than language expert so I did not know about nooks and crannies of the language. But that is exactly what was being asked in interviews and was never able to crack those interviews.

I liked Go and used to work on it in my personal time. Go's way of doing things is usually one way so there are not many things you have to remember about language. I applied for a job of Go and I landed that one. Of course, at that time very few Go developers were there in market so that could be a good reason for me landing that job as well.

Re:Why does `True == False is False` evaluate to False in Py... by rhizome on Saturday May 02, 2020 @02:23PM (#23053778)
It's about elegance, you see.

num%3 == 0 ? num%5 == 0 ? "fizzbuzz" : "fizz" : num%5 == 0 ? "buzz" : num