From: kj on 29 Oct 2009 16:48 How can one check that a Python script is lexically correct? As my Python apps grow in complexity and execution, I'm finding it more often the situation in which a program dies after a lengthy (i.e. expensive) run because the execution reaches, say, a typo. Of course, this typo needs to be fixed, but I'd like to find out about it before I waste hours on a run that is bound to fail. Is there any way to do this? I imagine the answer is no, because given Python's scoping rules, the interpreter can't know about these things at compile time, but I thought I'd ask. TIA! kynn
From: Mick Krippendorf on 29 Oct 2009 16:57 kj wrote: > How can one check that a Python script is lexically correct? By using pylint. Mick.
From: Diez B. Roggisch on 29 Oct 2009 16:59 kj schrieb: > How can one check that a Python script is lexically correct? > > As my Python apps grow in complexity and execution, I'm finding it > more often the situation in which a program dies after a lengthy > (i.e. expensive) run because the execution reaches, say, a typo. > Of course, this typo needs to be fixed, but I'd like to find out > about it before I waste hours on a run that is bound to fail. Is > there any way to do this? I imagine the answer is no, because > given Python's scoping rules, the interpreter can't know about > these things at compile time, but I thought I'd ask. pylint, pychecker, pydev. Maybe more. Diez
From: Robert Kern on 29 Oct 2009 17:32 On 2009-10-29 15:48 PM, kj wrote: > > How can one check that a Python script is lexically correct? > > As my Python apps grow in complexity and execution, I'm finding it > more often the situation in which a program dies after a lengthy > (i.e. expensive) run because the execution reaches, say, a typo. > Of course, this typo needs to be fixed, but I'd like to find out > about it before I waste hours on a run that is bound to fail. Is > there any way to do this? I imagine the answer is no, because > given Python's scoping rules, the interpreter can't know about > these things at compile time, but I thought I'd ask. I like using pyflakes. It catches most of these kinds of typo errors, but is much faster than pylint or pychecker. That means I can hook up a key macro to run it in my editor so I can use it frequently without hesitation (e.g. in Vim, it is my makeprg for Python files). It doesn't catch other stupid errors, of course. Try your best to write small, simple, quick-to-run tests for each piece of functionality that you are working on. Test the methods you've just coded independently of the rest of your code using that small test before doing full hours-long runs of the whole program. Bonus: you now have a suite of unit tests. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
From: Aahz on 29 Oct 2009 17:52 In article <mailman.2279.1256851983.2807.python-list(a)python.org>, Robert Kern <robert.kern(a)gmail.com> wrote: > >I like using pyflakes. It catches most of these kinds of typo errors, but is >much faster than pylint or pychecker. Coincidentally, I tried PyFlakes yesterday and was unimpressed with the way it doesn't work with "import *". -- Aahz (aahz(a)pythoncraft.com) <*> http://www.pythoncraft.com/ "You could make Eskimos emigrate to the Sahara by vigorously arguing -- at hundreds of screens' length -- for the wonder, beauty, and utility of snow." --PNH to rb in r.a.sf.f
|
Next
|
Last
Pages: 1 2 3 4 Prev: ImportError: No module named _md5 - Please help Next: self.__dict__ tricks |