Tabnanny really useful?

Steve Holden steve at holdenweb.com
Tue Dec 21 08:36:31 EST 2004


Franz Steinhaeusler wrote:

> On Tue, 21 Dec 2004 10:24:40 +0100, "Fredrik Lundh"
> <fredrik at pythonware.com> wrote:
> 
> 
>>Franz Steinhaeusler wrote:
>>
>>
>>>Thanks for your explanation.
>>>
>>>I tried an found:
>>>def a():
>>>->print
>>>->.print
>>>
>>>where point is a space.
>>>
>>>tabnanny here complains and python compile it just fine.
>>
>>really?  that's a syntax error (you cannot change indentation nillywilly
>>inside a block), and the Python I'm using surely flags this as an error:
>>
>>$ python -c "print repr(open('franz.py').read())"
>>'def a():\n\tprint\n\t print\n'
>>
>>$ python franz.py
>> File "franz.py", line 3
>>   print
>>   ^
>>SyntaxError: invalid syntax
>>
>>while tabnanny gives it one thumb up:
>>
>>$ python -m tabnanny -v franz.py
>>'franz.py': Clean bill of health.
>>
>>what Python version are you using?
>>
>></F> 
>>
>>
> 
> 
> Oh sorry, I meant
> def a():
> ->print
> ..->print
> 
> C:\Python23\Lib>tabnanny.py -v c:\franz.py
> 'c:\\franz.py': *** Line 3: trouble in tab city! ***
> offending line: ' \tprint\n'
> indent not equal e.g. at tab size 1
> 
> C:\Python23\Lib>python -c "print repr(open('c:/franz.py').read())"
> 'def a():\n\tprint\n \tprint\n'
> 
> C:\Python23\Lib>c:/franz.py
> 
> C:\Python23\Lib>

Well, you've probably answered your own question, then. Do you think 
tabnanny is a useful piece of code now? I used it a lot when I first 
started using Python, and still run it over code from unknown sources 
(no pun intended) from time to time.

regards
  Steve
-- 
Steve Holden               http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC      +1 703 861 4237  +1 800 494 3119



More information about the Python-list mailing list