7 ms·
I want to work in a group where they appreciate that I was basically born to code. That despite my youthful features, I have still been coding for over 30 year
by rabidrat 10y ago
I want to work in a group where they appreciate that I was basically born to code. That despite my youthful features, I have still been coding for over 30 years. That I can do many tasks in an hour, that other people would take days to do. That I will spend an extra 3 hours to put a cherry on top, just because I can. I may even do it on a Saturday, because code is what I like to do with my spare time too.
So when the last company I interviewed at asked me "what is the difference between range and xrange in Python?" I just kind of rolled my eyes (on the inside). To me this is like asking a professional translator "what is the difference between 'si' and 'sí' in Spanish?" They were not interested in the thousands of lines of code I have on GitHub for my side projects, nor in a recent project that got me 15 seconds of fame. I ended that interview by saying "I don't think I'm a good match for this job".
Different companies have different cultures. It's good to be able to identify the kind of culture you want to work in, and even better to be able to respectfully decline an opportunity because it doesn't work for you. Don't become bitter and think that all companies want you to be a coding robot, just because Google and Facebook do (or seem to; I'm not sure how many of my friends who work there actually have that many side projects either). There are plenty of jobs that will work for you that won't work for me, and vice versa.
- vigrante 10y agoThat's a pretty elaborate story to rationalize the fact you didn't know the difference between range and xrange....
- jonathankoren 10y agoThe correct answer is of course, is that xrange doesn't exist.
- logicallee 10y agoIn short, it's the default behavior in Python 3; it doesn't exist anymore: http://pythoncentral.io/how-to-use-pythons-xrange-and-range/ http://pythoncentral.io/how-to-use-pythons-xrange-and-range/ From that article (buried near the end for some reason): >One more thing to add. In Python 3.x, the xrange function does not exist anymore. The range function now does what xrange does in Python 2.x, so to keep your code portable, you might want to stick to using range instead.
- ant6n 10y agoso they removed it from python 3?
- brianwawok 10y agoAnd if they don't agree or laugh, time for a table flip.
- OJFord 10y ago`range` took the behaviour of `xrange`; the latter name was removed. https://docs.python.org/3/whatsnew/3.0.html#views-and-iterators-instead-of-lists https://docs.python.org/3/whatsnew/3.0.html#views-and-iterat...
- fencepost 10y agoI'd say that the correct answer would be "Which version of Python are you using?" but I actually kind of like the question - it's an important enough function that most people doing more than toy projects would have needed to use it at some point or at least would have considered it, but it's also something that has changed recently enough that people who are claiming long-term experience will have dealt with both versions. My Python is rusty, but I actually had to go look up the differences - my initial thought was "I'm pretty sure it used to be that range() generated a list and xrange() basically just iterated a value, but at some point range() was changed to use the xrange() behavior - I'd have to look it up to give you more detail than that." I didn't realize that xrange() had been completely removed from 3.x, for example. For that matter, I was thinking that both of them might have existed in 1.x, though it looks like they were added in 2.0.
- unethical_ban 10y agoIt doesn't need to be rationalized. I don't know it without googling it, but I can still get by writing some useful automation for Ops work. Granted, I haven't interviewed for a full-time Python gig, but even the one or two REALLY sharp programmers I know need to reference the web for a lot of stdlib stuff they don't use often.
- srssays 10y agoxrange vs range is basic competence for any Python 2 programmer. They are two of the most commonly used functions and have very distinct uses. I think that was the point of the original post, however, that the question is so basic it is actually insulting - like interviewing a doctor and asking the difference between red and white blood cells.
- drvdevd 10y agoI don't know this. And I don't care. I don't self-identify as anything near a "Python programmer" and yet I've written, modified, read, and debugged (and put into production at times), let's say 100's of thousands of lines of Python since the late 90s. Not a ton, perhaps, but I certainly feel qualified to write it. I'm forced to maintain (or deploy) other people's Python code all the time. Personally, I would rarely choose it for a team project I have to maintain (if the choice is mine) because I've seen most teams commit the same annoying type errors over and over in every dynamic language I've ever used, including epecially Python. I've worked with much more competent Python programmers than myself who still do this. But if I was on your team, I wouldn't complain and my code would be somewhere between pretty good to great. I would help the team ship that Python and ship it well. I'm not sure what this rant says more about: me or this 'range vs xrange' question?
- srssays 10y agoThe problem is that it's bad style to write (in Python 2.x): for i in range(n): # your code here because it potentially allocates a lot of memory for no reason whatsoever. It's the equivalent of this C code: int* r = calloc(sizeof(int), n); for (int j = 0; j < n; j++) r[j] = j; for (int j = 0; j < n; j++) { int i = r[j]; // your code here } free(r); If you don't want to deal with the distinction then what you can do is just treat range() as deprecated and always use either xrange() or list(xrange()) depending on the situation. But you had probably ought to know about the issue.
- dongslol 10y agoHe didn't say he didn't.
- gravypod 10y agoUnless you've written a lot of Python 2, or ported a lot of it in my case, then you wouldn't know. It's a stupid question with little basis in actually seeing if someone know's what they are talking about.
- jghn 10y agoReally? I used python for a few years a long while back and I thought that this was common knowledge. Perhaps it was the timing of it all as I now that I google around a bit most of the SO posts and such are from when I was writing Python.
- ldev 10y agoSome people aren't born to code...
- eps 10y agoThe range/xrange question was likely to check if you were a fraud. Having interviewed close to a hundred people in a year for a senior C dev position I can assure you that people lie like you wouldn't believe. They cheat with take-home tasks, they show others' code as their own. And that's in the system programming circles, where the level of professionalism is typically much higher than in app/web development areas. We got burnt really bad when a brilliant dude whom we relocated across the country turned out to be the laziest moron I've ever had a misfortune to work with. So you bet we started most of the interviews with fuzz-buzz kind of questions.
- jknoepfler 10y agoOn the other hand, I'm a skilled dev with only a smattering of python experience, but if you asked me this question I'd have no idea and wouldn't think twice about looking up the python docs for both. What are you actually asking? P.s. I don't believe anyone actually fails fizz buzz.
- xyzzy_plugh 10y agoPeople fail fizz buzz all the time.
- jknoepfler 10y agoI don't believe that. I'd really like a 21st century study showing that devs with > 3 years of experience fail fizz buzz, and that failure is predictive of being a bad developer (and not being a shitty interviewer)
- hafriedlander 10y agoIf you don't believe Jeff Atwood, I'm not sure why you'd believe me based just on my anecdata, but at a previous job I gave a simple filtering programming task to interviewees (not exactly fizz buzz, but very close. Single loop, multiple 10-line solutions possible). Out of 10, only 1 solved it well, 2-3 solved it acceptably (only edge case bugs), the rest never solved it, or had obvious bugs or code that would never pass peer review. Of course, I could just be a shitty interviewer, but I always had a (changing) peer present during interviews, and I hope we were an honest enough company that they'd tell me if they thought I was.
- gdulli 10y agoKnowledge of the deepest arcana of the Python language is less valuable than the humility and self-awareness that keeps one from forming fast conclusions based on little data.
- rabidrat 10y agoOh how I wish I had that skill! And the complementary skill of knowing when what little data you have is totally enough and you should trust your gut instinct. I've waited far too long to make a decision when the answer should have been clear a long time ago.
- booleandilemma 10y agoOn the other hand, I think it's a good idea to sanity test your candidates, especially when it feels like everyone is trying to pass themselves off as a developer nowadays.