Style question

L

Leif K-Brooks

The style guide says that a wrapped line should be aligned with where
the wrapped part started. But what is the most readable thing to do when
that's impossible? For instance (ignore the wrap caused by my news
reader), where should the second variable name be wrapped to in this line?

really_really_long_variable_name =
another_even_longer_variable_name_with_cookies
 
P

Peter Hansen

Leif said:
The style guide says that a wrapped line should be aligned with where
the wrapped part started. But what is the most readable thing to do when
that's impossible? For instance (ignore the wrap caused by my news
reader), where should the second variable name be wrapped to in this line?

really_really_long_variable_name =
another_even_longer_variable_name_with_cookies

Ignoring the style guide on this issue, I always indent wrapped
lines one indentation level beyond the previous line.

"It's the only thing that makes sense." (TM)

-Peter
 
A

Albert Hofkamp

The style guide says that a wrapped line should be aligned with where
the wrapped part started. But what is the most readable thing to do when
that's impossible? For instance (ignore the wrap caused by my news
reader), where should the second variable name be wrapped to in this line?

really_really_long_variable_name =
another_even_longer_variable_name_with_cookies

To me, a style guide is a _GUIDE_, not a _LAW_.
So for cases that are not covered, do something sensible in the spirit
of the guide.

(what also may help is ask yourself the question whether you really want
to do something that doesn't fit the style guide. In many cases,
doing something outside 'normal' is an indication that there are
alternative (better?) solutions.)

Albert
 
?

=?iso-8859-1?Q?Fran=E7ois?= Pinard

[Leif K-Brooks]
But what is the most readable thing to do when that's impossible? For
instance, where should the second variable name be wrapped to in this
line?
really_really_long_variable_name =
another_even_longer_variable_name_with_cookies

I would suggest one of two writings. Some people would do:

really_really_long_variable_name = \
another_even_longer_variable_name_with_cookies

yet I prefer:

really_really_long_variable_name = (
another_even_longer_variable_name_with_cookies)

because I like to avoid escaped newlines (save in triple-quoted strings).
 
B

bruno modulix

Leif K-Brooks a écrit :
The style guide says that a wrapped line should be aligned with where
the wrapped part started. But what is the most readable thing to do when
that's impossible? For instance (ignore the wrap caused by my news
reader), where should the second variable name be wrapped to in this line?

really_really_long_variable_name =
another_even_longer_variable_name_with_cookies

<troll>
Isn't there something in the style guide about
really_really_long_variable_name ?-)
</troll>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top