On 7 May 2005 15:05:20 -0700, "LDD" <[EMAIL PROTECTED]> wrote:
>Hi everyone, > >I am new to python and was very enthustic about its possibilities when >I discover that python is really what it is : just a scripting >language. > >What disappoints me is that pyton will happily accept and execute this >code : > >if ( aConditionThatIsFalse ): > AFunctionThatIsntDefined() > >print "Hello world" > and will happily and correctly print "Hello world" ... what's your beef? You have tested one part of your program. Now, go away and test the remainder of your program! >The fact that python doesn't check if the symbol >AFunctionThatIsntDefined is defined, is really bad It does check, when you dereference the symbol. If that dismays you, what about this: def func1(argfunc): argfunc() or, a real practical example: reading a flat file with columnar data, each column may need some conversion or data-fixing depending on its type etc. fixed_row = [] i = -1 for x in input_row: i += 1 fixed_row.append([conv_func[i](x)) The dynamic nature of Python -- and there's a whole lot more than functions (and methods) being first-class-citizen data objects -- allows much more code to be written faster cleaner fat-free and allow more time for writing tests. > when you develop big >pieces of code. You will never be sure that your code is free of this >kind of dummy errors and testing every possible execution paths is >nightmarish ! What about AFunctionThatIsDefinedButIsBuggyAndInsteadOfOrderingInPizzaLaunchesAPremptiveMissileStrike() It is a nightmare, isn't it? If you are employed by a firm that makes things like avionics, railway signalling equipment, or heart pacemakers, would you please let us know the brand(s)? > >Is there a way to force Python to check the definition of symbol ? No. However you may use pychecker to pick up the spelling mistakes and a whole lot more besides. -- http://mail.python.org/mailman/listinfo/python-list