Without compilation, how to find bugs?
BartC
bc at freeuk.com
Fri Oct 14 05:04:49 EDT 2016
On 14/10/2016 01:59, sohcahtoa82 at gmail.com wrote:
> On Thursday, October 13, 2016 at 4:06:36 PM UTC-7, pozz wrote:
>> Are the things exactly how I understood, or do I miss something in Python?
>
> As others have said, user a linter.
With Python you're supposed to just be able run any source code
instantly; how will using a 'lint' tool impact that process? Or is it
only meant to be used infrequently?
> 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.
How can that work? I thought one of the biggest deals with Python is
that you can re-bind function names to anything else. So:
if cond:
func2 = 38
else:
func2 = func1
Then func2(1) can either be perfectly correct, or completely erroneous!
(I have my own suspicions that functions in Python are predominantly
used in a boring, predictable, static manner (so allowing certain
optimisations - or error checking), but I got the impression from some
threads here that many apparently do little else in their code but bind
and rebind function names.)
--
Bartc
More information about the Python-list
mailing list