pychecker question
Roman Suzi
rnd at onego.ru
Thu May 16 13:31:15 EDT 2002
On Thu, 16 May 2002, Neal Norwitz wrote:
>On Mon, 13 May 2002 09:29:46 -0400, Roman Suzi wrote:
>
>> Hi!
>>
>> I am pychecking my code and am getting lots of:
>>
>> stable.py:210: Variable (path) used before being set
>> stable.py:210: Variable (split) used before being set
>> stable.py:224: Variable (strip) used before being set
>> stable.py:226: Variable (index) used before being set
>> stable.py:261: Variable (join) used before being set
>> stable.py:261: Variable (replace) used before being set
>>
>> These are caused by from-import statements inside functions,
>> schematically:
>>
>> def f(x):
>> from m import y
>> return y(x)
>>
>> Is it really considered bad to use from-import inside function
>> definition? (I did it because I wanted to state clearly which functions
>
>I don't think it is particularly bad. It could be a bug in pychecker.
>Which version of pychecker & python?
python 1.5.2 (same with 2.1, IIRC)
pychecker-0.7.5
$ rpm -qf /usr/bin/pychecker
pychecker-0.7.5-1
[rnd at rnd rnd]$ cat aaa.py
def f(x):
from m import y
return y(x)
[rnd at rnd rnd]$ pychecker aaa.py
Processing aaa...
Warnings...
aaa.py:1: No module doc string
aaa.py:6: Variable (y) used before being set
>> I am using from there. And I do not want to use it at the module level,
>> like that:
>>
>> from m import y
>> def f(x):
>> return y(x)
>>
>> as I think it will increase the number of imports.
>
>Actually, this will decrease the number of imports. This will be done
>only once for the whole program. Whereas if the import occurs within a
>function, the byte codes will be executed for each function call. The
>import work (actually reading file, etc) will still only be done once,
>regardless of where the import is.
I am using modules with individual scripts, so the less
module to load, the better.
>> Another question. Is there any front-end to pychecker to show code in
>> proper context and an ability to silence certain warnings just like I do
>> in ispell if I consider some word correct?
>
>There is a simple GUI which isn't documented: pychecker/options.py. But
>you are probably much better off with an IDE, emacs, boa, or wingide.
>(I've only used emacs.)
pychecking from Emacs? I can't find anything under C-h b
in python-mode...
>There are many ways to silence warnings: using __pychecker__ in your
>code, .pycheckrc file, or the command line all work. Probably the best
>way is .pycheckrc. There is a sample one in the distribution (pycheckrc).
Can't locate it on my machine...
> The main page should have a brief description of most of this info:
>http://pychecker.sf.net.
>
>Neal
Thank you Neal
Sincerely yours, Roman Suzi
--
\_ Russia \_ Karelia \_ Petrozavodsk \_ rnd at onego.ru \_
\_ Thursday, May 16, 2002 \_ Powered by Linux RedHat 7.2 \_
\_ "Can't learn to do something well? Learn to enjoy doing it badly!" \_
More information about the Python-list
mailing list