On Thursday, October 13, 2016 at 4:06:36 PM UTC-7, pozz wrote: > I come from the C language, that is a compiled and strongly typed > language. I learned many good tricks to write good code in C: choose a > coding style, turn on as many warnings as possible, explicitly declare > static variables and functions (when needed), explicitly declare const > variables (if the piece of code will not change them), explicitly > declare all the functions, and so on. > > All the tricks have a common goal: to discover bugs as soon as possible, > mostly during compilation process. Indeed I usually find some bugs > during compilation (or static analysis). It seems to me very important. > > Now I'm learning Python and it appears to me very simple, but at the > same time highly dangerous. For example, I can write a function that > accepts two arguments and call it with only one argument. I can execute > the script without any problem and I will not notice the bug until I > test exactly the erroneous line of code (the call with only one argument). > > However, I think the language interpreter could emit the error before > launching the script even without executing the wrong instruction, > because it perfectly knows how many arguments the function wants and > that one instruction calls it with a wrong number of arguments. > > Are the things exactly how I understood, or do I miss something in Python?
As others have said, user a linter. I'd go a step further and use an actual code editor or IDE that includes some basic static analysis. Using this example that Skip used: def func2(a, b): print(a, b) def func1(a): print(a) func2(1) Any code editor worth using will highlight the ) on the last line and tell you that there's a missing parameter. -- https://mail.python.org/mailman/listinfo/python-list