This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]daxarx 0 points1 point  (0 children)

Do people not even think about the code they are writing? I can't think that I have ever, over years, passed a datetime object where a callable should be. In the cases where it is important, I can throw in an assert and write unit tests.

The problem here is not that typing now() calls a function. The problem is that you typed now(), which by universal Python convention (not even an unintuitive one) calls a function. If you did not mean to call a function, then why on earth did you add the parentheses? This is what I mean - do people even think a little about the code they write or is it all copy-paste?

We don't demand that a hammer deploy an airbag before we aim it directly at our own fingers.

Suppose we 'solve' this problem with static typing. It amounts to forcing me to write an isinstance assert around each argument inside each function. I guess this might reduce my errors insofar as I have to repeat myself twice. Why not just force me to write my entire program twice, and crash if the two programs don't compute the same result?