Hacker News new | past | comments | ask | show | jobs | submit login

One is left with very little doubt about the quality of such resources, when you see examples like [0]:

  def sum(list):
      sum = 0
      for l in list:
          sum = sum + l
      return sum

  mylist = [1,2,3,4,5]
  print(sum(mylist))
Hint: Observe the name of (1) the function, (2) the parameter therein.

[0] http://askpython.com/functions/




I recently failed a Google interview. I used Python. I believe I did solve the problem, but my code might have been the deciding factor in rejecting me. My code looked similar to this. For example, I implemented my own `min`. Which did a O(N) walk of the array. Probably a horrible choice on my end. Looking back I should have used more builtins.


Nitpick: The built-in min() is also O(n) on the length of the array, though it will be a bit faster as a built-in C function.

You're probably right that you shouldn't have reimplemented it though - knowing how to use the language and its standard library is a good indicator for real-word experience.


This was for a new grad role though. I'm just about to get out of college. Looking back , I really fucked up by not using Pythonic style. The only reason I chose python is because of it's string handling capabilities, etc as opposed to C - where I'd have to implement boiler plate stuff most likely, and worry about resizing arrays, etc.


For a company that takes around two months to review your profile and/or compare it with other candidates (or whatever they do during that time) I expect less arrogance during these code challenges because I am yet to find a developer who can write code like a robot.


What do you mean arrogance?


I agree that the choice of names is unfortunate. Still I think it's permissible in example code to redefine functions with your own implementation. At this point shadowing built-ins is unlikely to confuse anybody.


Learning things is fun. Having to unlearn things seldom is. This set bad habits in a discipline where a lot is muscle memory. I don't think it's a good idea.

Furthermore, I tried hard to ignore the glaring similarities between this and Zed Shaw's "Learn Python the Hard Way" from the way the course is structured down to some expressions.

This would have been cool if it at least mentioned the course on the right side pane with the other recommendations.


What's wrong with that


They're shadowing builtins. Python's list type can't be referenced by its name in the defined sum function and Python's sum function can't be used in or after the new function's definition.

One could argue that in a source meant to teach Python, it shouldn't use examples that don't follow best practices. I feel that as a resource to, from the page, "learn how to write code, the basics and see examples" that it doesn't really matter too much.


I thought GP's issue was that the function is shadowing itself within itself, which I think is worse than shadowing a builtin with a similar function.


And using "list", which IIRC is a reserved keyword


I had completely missed that one. That is pretty bad and confusing.


I learned to program in PHP and builtins tripped me up a LOT as a new programmer. Talk about wrapping your head around some things when you're brand new.


This kind of thing leads to many "wait, what?" moments... confusing and aggravating to someone just learning syntax.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: