Live data from Hacker News

Interview gone wrong

ashu1461.com

11–20 of 209 posts

Re: Interview gone wrong

#11
post #2

Any time you use language specific tricks in an interview, you’re probably going to confuse your interviewer and not do well.

I disagree: if you are demonstrating your mastery of a language (and with Python, these things are important: using appropriate syntax is the difference between dog slow code and fast code), you should use idiomatic patterns like the above.

Another of Python features is a great REPL: when unsure or confused by an interviewer, I'd just fire python from shell and type in 'x' == 'x' == 'x' to confirm and demonstrate it does the right thing (or write tests).

Obviously, the interviewer should be careful not to sidetrack the candidate much, and let them do the work and attempt to help only if things don't work out.

Re: Interview gone wrong

#12
post #2

Any time you use language specific tricks in an interview, you’re probably going to confuse your interviewer and not do well.

But it's not a "trick", it's just a normal Python code.

I don't think that anyone who main programs in Python would perceive it as some kind of cool/unusual trick and not just normal code.

Re: Interview gone wrong

#14
post #2

Any time you use language specific tricks in an interview, you’re probably going to confuse your interviewer and not do well.

I suspect the interviewer would have likely been fine if they’d been able to explain chained comparisons and how they work. I would probably consider the interviewer using them without understanding them to be a negative signal.

Re: Interview gone wrong

#15
In this respect, Python makes a lot more sense since that is how you'd normally write such an equality in math, and generally how people chain them: A=B=C means A=B and B=C.

Part of the problem here is that we treat true/false as "just another value" in programming, and thus the usual operators are used to compare them. In math notation, if you wanted to compare the result of comparison A=B to a Boolean value C, you'd normally write something like (A=B)≡C, using different operators for equality and equivalence.

Interestingly, programming languages haven't always treated Booleans in this way. If you look at ALGOL 60, it starts by cleanly separating expressions into arithmetic and logical ones, and defines completely different sets of operators for each (the reference language also uses = for numeric comparisons and ≡ for Booleans; and boolean inequality is, of course, just XOR).

Re: Interview gone wrong

#17
post #2

Any time you use language specific tricks in an interview, you’re probably going to confuse your interviewer and not do well.

If you're used to python, you wouldn't consider it to be a trick.

If you're giving interviews, and evaluating code in a language you don't know, don't be so confident it's wrong. Ask the candidate how it works.

Re: Interview gone wrong

#18
The candidate was writing an accounting program in COBOL and he wrote "ADD 2 TO SUM.". None of the handful of languages I kind of know support that syntax. It turns out that COBOL actually supports this nonsense. I explained to the candidate that when he is writing valid COBOL syntax, it is confusing to people who don't know COBOL and he agreed.

This is a fail for the interviewer, not the interviewee, nor for Python.

Re: Interview gone wrong

#19

I don't know why didn't the candidate just explain to the interviewer what chain expressions are.

Sounds like he didn't know the details, but had seen this pattern in Python code and knew it worked. When asked, he was confused about the exact details of why it worked.

Re: Interview gone wrong

#20

Python evaluates `2 == 2 == 2` to true. JavaScript evaluates the same to false. Somehow we've decided that Python is the weird one it seems.

1 == 1 == 1 is actually true in Javascript due to type coercion

You're probably thinking `1 === 1 === 1` which is indeed false

Post reply on HN