Linebreaks and Indention
Daniel Calvelo Aros
dcalvelo at minag.gob.pe
Wed Mar 24 19:25:07 CET 2004
On Wed, 24 Mar 2004 18:48:33 +0100, Martin Schulze wrote
> I noticed that python-mode *and* Python behave "a little bit" strange
> to linebreaks.
>
> If I try to break a longer line inside python-mode
>
> foo_bar_baz = bar
>
> auto-indention creates:
>
> foo_bar_baz = \
> bar
>
> which only saves two characters width, which is rediculous.
>
> Do you want the second line indented by 4 characters or zero
> characters? I.e.
>
> foo_bar_baz = \
> bar
>
> or
>
> foo_bar_baz = \
> bar
>
> The latter is created by python-mode/auto-indent if one splits the
> line without inserting a backslash at once. Surprisingly Python
> will accept both.
>
> Another question is how you prefer to break long lines with
> function/method calls like
>
> foo_bar_baz(baz_bar
>
> Emacs python-mode/auto-indent automatically indents properly if
> split after an opening paranthesis:
>
> foo_bar_baz(
> baz_bar
>
> but not if split before the parentheis:
>
> foo_bar_baz
> (baz_bar
>
> Surprisingly Python will accept both. But which one do you prefer?
In almost all cases, I try to indent by four spaces.
Only exceptions are complicated expressions involving nested function calls,
where I try to indent each functions arguments according to the expression
structure, like:
outer_call(
tricky_function(
arg_foo,
arg_baz = bar,
arg_bar
),
further_function(
with,
its,
own = args
)
)
But that could as well be
outer_call(
tricky_function(
arg_foo,
arg_baz = bar,
arg_bar
),
further_function(
with,
its,
own = args
)
)
And we are back to the always-four-space-indent rule.
Another interesting indentation layout is in generators, when they won't fit
in a line. I'd rather have:
[ very_long_expression
for var in seq
if condition ]
than
[ very_long_expression for
var in seq if condition ]
if that's what autoindent generates.
BTW, opening brackets always at the end of the line. Old habit from the days
where python wouldn't accept multi-line expressions sans backslash except with
an unclosed bracket.
Just my taste of it. Are you trying to build consensus? Stuff like this should
be in the guidelines.
Daniel.
> Regards,
>
> Joey
>
> --
> Still can't talk about what I can't talk about. Sorry. -- Bruce Schneier
>
> Please always Cc to me when replying to me on the lists.
>
> _______________________________________________
> Thuban-devel mailing list
> Thuban-devel at intevation.de
> https://intevation.de/mailman/listinfo/thuban-devel
-- Daniel Calvelo Aros
-- Dirección General de Información Agraria
-- Ministerio de Agricultura del Perú
-- (51-1)424-9001
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)