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

Quick question:

Why does

  35: chosen = random.choice(movies)
at https://github.com/infobyte/spoilerwall/blob/master/server-s... have a reference to 'movies'. I thought one had to explicitly pass it to the MyTCPHandler class using the server object? Or is this a special case because of __main__?



If the file gets executed as a script, then __name__ == "__main__", hence L43:53 get executed in the top-level scope, which is also available in the lower levels. This isn't very good writing, since this code will throw exceptions when __name__ != "__main__" (i.e. when import-ing the file as a module), which misleadingly defeats the purpose of having that conditional there.


Ok, thanks, that makes sense. I knew that top-level variables are global, but didn't know that variables in __main__ share this property (which is e.g. different in the C language).


Usually people write an actual function called main(), and call it from the global level conditional, to avoid this oddness. The actual function called main() has no special meaning in python.


if __name__ == __main__ is just a conditional on the top level scope.


> Quick question

I'm always wondering why people prefix a question with the statement "quick question". Now is my chance to ask. Is the question typed quickly? Should I imagine you speaking it in a quick manner? Is it meant as "off topic question"? Do you expect an answer quickly? What does it mean when you prefix your question with the words "quick question"?


It means that the asker believes the question is relatively short and thus won't be too much of a burden on the askee.


IME it's often used as a sort of sarcastic parody, to emphasise that the element of the person's statement being questioned hasn't been resolved and the whole situation is contingent on the answer.

For example, when PM May had finished presenting her new manifesto before the election one might ask "Quick question: how are you going to pay for all that?" to highlight the fact that no costings had been included and suggest you thought it was unrealistic (or hiding tax rises, or whatever).

"Quick question" is used genuinely too. One use appears to be "don't go too deep, give me a superficial answer".


Ah, I understand. Like "what is mass" or "who killed JFK". Simple questions like that.


I concur - that was the reason at least for me.

Actually I am not a native English speaker, I translated it literally from German where we also say "Kurze Frage [...]".


In German you would use it to get a short answer to a short question, for example a yes/no question or when you ask about the time. In practice the shortest answer possible with the notice that you are just looking for a quick answer without explanations. Normally you use it to let the other know that it will not take long and you don't want to disturb.




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

Search: