Default indentation of 4 columns

Greg McFarlane gregm at iname.com
Sat Oct 30 06:12:41 EDT 1999


On 24 Oct, François Pinard wrote:
> The only thing that really rebukes me is the interdiction to use capitals in
> comments to mark non-terminals (or variables), as it does not get accompanied
> by a better suggestion, or at least, none yielding as much clarity.

Not sure what you mean here...

> The 4 columns indentation rule is quite acceptable on average, expect when
> I have things like, say:
> 
>     for file_name, line_number, function_name, python_text in frames:
>         if (function_name[0] not in ('_', '<')
>             and function_name not in transparent_functions):
>             name = os.path.basename(file_name)
>             if name not in transparent_files:
>                 return name, line_number
> 
> The pseudo-alignment of the `and' with `name' is rather ugly to my eyes.
> It would be alleviated a bit by using `\' on the preceding line instead
> of `(', but the style guide suggests that we favour '(', which looks
> like a good thing.  Do some of you share my little irritation, here?
> Would someone have developed some elegant and easy compromise?  I hardly
> see one, but who knows, people sometimes have unexpectedly good ideas! :-)

I normally add an extra level of indentation to make the second line
of the if statement stand out:

    for file_name, line_number, function_name, python_text in frames:
        if (function_name[0] not in ('_', '<')
                and function_name not in transparent_functions):
            name = os.path.basename(file_name)
            if name not in transparent_files:
                return name, line_number

It stands out because this kind of indenting is otherwise illegal in
python:  "inconsistent dedent".

-- 
Greg McFarlane     INMS Telstra Australia     gregm at iname.com




More information about the Python-list mailing list