P
PyPK
What possible tricky areas/questions could be asked in Python based
Technical Interviews?
Technical Interviews?
PyPK said:What possible tricky areas/questions could be asked in Python based
Technical Interviews?
PyPK said:What possible tricky areas/questions could be asked in Python based
Technical Interviews?
I may branch out into more advanced stuff such as asking
for an example use case for a closure, a custom descriptor, or an import
hook, for example
Andrew Durdin said:Isn't that approaching things from the wrong angle? You're asking them
to synthesise a problem for a given solution, rather than analyse a
problem to determine an appropriate solution. Asking questions like
these tests memory more than competence -- for example, if you ask me
of a use case for a closure, the only answer I could give would be to
remember a problem I'd solved in the past using one.
PyPK said:hmm Thats one thing. Also I was thinking of something like benefites of
python over other languages.
Alex said:I like to present code that seems like it should work, but has some kind
of relatively subtle problem, either of correctness in some corner case,
or of performance, etc -- and I ask them what they would say if they
were to code-review that code, or how they would help a student who came
to them with that code and complaints about it not working, &c.
[snip]
Not sure whether you think this count as "tricky"... they're typically
problems that do come up in the real world, from (e.g.):
for string_piece in lots_of_pieces:
bigstring += string_piece
(a typical performance-trap) to
for item in somelist:
if isbad(item):
somelist.remove(item)
(with issues of BOTH correctness and performance), to
class Sic:
def getFoo(self): ...
def setFoo(self): ...
foo = property(getFoo, setFoo)
to
class Base(object)
def getFoo(self): ...
def setFoo(self): ...
foo = property(getFoo, setFoo)
class Derived(Base):
def getFoo(self): ....
Steven said:Alex Martelli wrote:
Those two are easy. However, and this is where I show my hard-won
ignorance, and admit that I don't see the problem with the property
examples:
Unless the answer is "Why are you using setters and getters anyway? This
isn't Java you know."
Oh wait! Yes I do... the setter doesn't actually take an argument to set
the property too. Is that it, or have a missed a cunningly hidden deeper
problem?
Steven said:Those two are easy. However, and this is where I show
my hard-won ignorance, and admit that I don't see the
problem with the property examples:
Steven D'Aprano said:my hard-won ignorance, and admit that I don't see the
problem with the property examples:
Unless the answer is "Why are you using setters and
getters anyway? This isn't Java you know."
Alex said:[snip]
the solution, in Python 2.4 and earlier, is to use
one extra level of indirection:
def __getFoo(self): return self.getFoo()
def getFoo(self): ...
foo = property(__getFoo)
so the name lookup for 'getFoo' on self happens when you access s.foo
(for s being an instance of this here-sketched class) and overriding
works just as expected.
beza1e1 said:let me try.
1) ''.join(lots_of_pieces)
2) This doesn't even work, if something is removed, the list is too
short. So:
[x for x in somelist if not isbad(x)]
well, list comprehension is Python 2.4 and 2.3 is the standard in many
OSes, so it is possibly not the most portable solution
I had to look up the syntax, because i never use it in my code, yet.
>>> [a.upper() for a in ['two', 'point', 'two']] ['TWO', 'POINT', 'TWO']
>>>
regards3+4) I never used property - had to look it up. So i learned something
![]()
beza1e1 said:well, list comprehension is Python 2.4 and 2.3 is the standard in many
OSes, so it is possibly not the most portable solution
beza1e1 said:let me try.
1) ''.join(lots_of_pieces)
Yep.
2) This doesn't even work, if something is removed, the list is too
short. So:
[x for x in somelist if not isbad(x)]
well, list comprehension is Python 2.4 and 2.3 is the standard in many
OSes, so it is possibly not the most portable solution
I had to look up the syntax, because i never use it in my code, yet.
3+4) I never used property - had to look it up. So i learned something
![]()
PyPK said:What possible tricky areas/questions could be asked in Python based
Technical Interviews?
Tim said:What's the point of asking "tricky" questions? Aren't you really more
interested in what applications they have worked on and whether they were
successful?
I don't know. I'm not sure I need a job with a company that insists on
playing "Programming Jeopardy" during the interview.
Alex said:No, LC goes back a long way -- I think it was in 2.0 already, 2.1 for
sure.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.