Default indentation of 4 columns
Michael Hudson
mwh21 at cam.ac.uk
Sun Oct 24 13:42:36 EDT 1999
=?ISO-8859-1?Q?Fran=E7ois_Pinard?= <pinard at iro.umontreal.ca> writes:
> Hi, people. I'm reasonably trying to follow Guido's style guide, somewhat
> helped in doing so by the nice Emacs Python mode.
>
> 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.
>
> 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?
Yes.
> Would someone have developed some elegant and easy compromise? I hardly
> see one, but who knows, people sometimes have unexpectedly good ideas! :-)
It hadn't occurred to me before, but one `solution' would be to chuck
another space between `if' and `(', like so:
def r():
if (long_condition
and other_condition):
return ineteresting_stuff
Not especially natural, but it might just work...
HTH,
Michael
More information about the Python-list
mailing list