variable declaration
Alexander
Alexander_Zatvornitskiy at p131.f3.n5025.z2.fidonet.org
Sat Feb 5 05:31:37 EST 2005
Привет Peter!
31 января 2005 в 09:09, Peter Otten в своем письме к All писал:
PO> pychecker may help you find misspelled variable names. You have to
PO> move the code into a function, though:
PO> $ cat epsilon.py
...skipped...
PO> $ pychecker epsilon.py
PO> epsilon.py:6: Local variable (epselon) not used
Well, I can change it a little to pass this check. Just add "print epselon"
line.
I think if as soon as I will make such error, I will write special checker. It
will take code like this:
def loop():
#var S,epsilon
epsilon=0
S=0
while epsilon<10:
S=S+epsilon
epselon=epsilon+1
print S
Such checker will say "error:epselon is not declared!" if I will use something
not declared. If everything is ok, it will call pychecker. Simple and tasty,
isn't it?
Of cource, it may be difficult to handle fields of classes:
MyClass.epsElon=MyClass.epsilon+1
but it is solvable, I think. What do you think, is it a good idea?
Alexander, zatv at bk.ru
More information about the Python-list
mailing list