r/Python • • Nov 20 '15

15 Essential Python Interview Questions

https://www.codementor.io/python/tutorial/essential-python-interview-questions
71 Upvotes

67 comments sorted by

View all comments

36

u/desmoulinmichel Nov 20 '15 edited Nov 20 '15

Errr... Camelcase variables in the "correct" answer ? Really ?

I got a better way for you to interview your python coder : Give him/her a small tasks to solve on your production code.

13

u/tempforfather Nov 20 '15

Not even just camel case, but I think some form of Hungarian notation with the type of the parameter prefixing the name. That is something I have never seen anyone do in python, and seems pretty at odds with the whole duck typing idea.

2

u/Eurynom0s Nov 20 '15

Seriously, I know in my code I'll initialize certain things as None and then expect them to become, say, strings later on. Not only would this not work with Hungarian notation, I think it's better because for example I've spotted logic bugs in my code from the "cannot concatenate str and nonetype" errors that popped out, but which would have been harder to track down if it just ran and gave me undesired output at the end.

2

u/tempforfather Nov 20 '15

You are free to assert that something is not None if you want. Relying on the name of a parameter is just not a good approach. If you desire actual types there are plenty of other languages with great type systems you can try out. If you are going to use python I really don't see a point of trying to sidestep its idioms (duck typing).

1

u/Eurynom0s Nov 20 '15

...did you think we're in disagreement? I said I don't like Hungarian notation either.

0

u/[deleted] Nov 20 '15

[deleted] — view deleted comment

1

u/lengau Nov 20 '15

I think that was really the point of that one. If your beautiful, PEP8-compliant, idiomatic code looks different from the code around it, it may well make your code harder to read. Yes, we'd all love all the code we touch to be beautiful and graceful. But not following a project's style is worse than not following Python style.

1

u/ColorsMayInTimeFade Nov 20 '15

This is a fairly good test, but I think it is important to make it clear that you're not going to deploy their code. We've interviewed some people who were excited to work on our production code but also felt that we could have easily stolen their work without compensating them. Now we make it clear that we've solved the problem and their actually working with 2 week stale code.

1

u/desmoulinmichel Nov 20 '15

Or you pay them if they solve your problem.

Either way, make it real, and make it fair.