[Eric] Indentation check not working fine?

Detlev Offenbach detlev at die-offenbachs.de
Wed Dec 31 15:05:15 GMT 2008


On Mittwoch, 31. Dezember 2008, Geert Eric4 wrote:
> Hi,
>
> I'm taking my first steps in using eric4 to create and debug Python
> applications.
> Since I'm also quite new to Python, I'm trying to write the (important)
> indents as much as possible correct immediately.  However, nobody's
> perfect, that's why I find it very good that eric4 has a tool/option to
> check the indentations (when you're editing a Python file, right-click
> and select "Check -> indentations...").
>
> However, I tried out the tool with the following small piece of code:
>
> import wx
>
> class MainWindow(wx.Frame):
>     """ We simply derive a new class of Frame. """
>     def __init__(self, parent, id, title):
> wx.Frame.__init__(self, parent, id, title, size=(200,100))         <===
> THIS LINE HAS A WRONG INDENT
>         self.control = wx.TextCtrl(self, 1, style=wx.TE_MULTILINE)
>         self.Show(True)
>
> app = wx.PySimpleApp()
> frame=MainWindow(None, wx.ID_ANY, 'Small editor')
> app.MainLoop()
>
> As one can see, after the "def __init__()" line, there's a ":", so the
> next line *must* be indented.  I deliberately started the new line at
> the leftmost position and ran the indentation check.
>
> To my surprise, the check passed, while I would have expected to see a
> failure here.
>
> In the editor itself, on the other hand, checking this looks good
> because I saw the "red bug" on the left for as long as the indentation
> was not correct.
> Then I saw that "Check -> Syntax..." was giving me the error, as long as
> any of the indentations were incorrect.
>
> What's the difference between "Check -> Indentations..." and "Check ->
> Syntax..." with respect to indentations?  This difference is not clear
> to me...

Check->Indentations checks for Whitespace related problems using the standard 
Python module tabnanny. Feeding your script to tabnanny (python -mtabnanny 
script.py) doesn't result in an output meaning, everything is ok. Tabnanny 
basically checks for identations that use a mixture of tabs and spaces. It 
doesn't catch syntax errors. That is the job of Check->Syntax.

Regards,
Detlev
-- 
Detlev Offenbach
detlev at die-offenbachs.de


More information about the Eric mailing list