Python Newbie
Joshua Landau
joshua.landau.ws at gmail.com
Sun Feb 24 16:58:36 EST 2013
On 24 February 2013 20:48, Roy Smith <roy at panix.com> wrote:
> In article <mailman.2434.1361738581.2939.python-list at python.org>,
> Chris Angelico <rosuav at gmail.com> wrote:
>
> > On Mon, Feb 25, 2013 at 7:34 AM, MRAB <python at mrabarnett.plus.com>
> wrote:
> > > Some languages require parentheses, others don't.
> > >
> > > C does. C++, Java and C# are descended from, or influenced by, C.
> > >
> > > Algol didn't (doesn't?). Pascal, Modula-2, Oberon, Ada, and others
> > > don't.
> > >
> > > Parentheses are used where required, but not used where they're not
> > > required, in order to reduce visual clutter.
> >
> > And just to muddy the waters, parens are used in Python when the
> > condition goes over a line break:
> >
> > if (condition1
> > and condition2
> > and condition3):
> >
> > ChrisA
>
> That could also be written:
>
> if condition1 \
> and condition2 \
> and condition3:
>
> but as a practical matter, I would write it in the parens style, if for
> no other reason than because emacs does a better job of auto-indenting
> it that way :-)
>
Pah,
condition1 = long_condition_expression_1
condition2 = long_condition_expression_2
condition3 = long_condition_expression_3
if condition1 and condition2 and condition3:
STUFF
No multiline needed. If you have *many* conditions, then:
supercondition = all(
condition1,
condition2,
condition3,
condition4,
condition5,
condition6,
condition7,
condition8,
condition9
) # or equiv.
if supercondition:
STUFF
Reason:
Indentation should be *really simple*.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130224/b896dc57/attachment.html>
More information about the Python-list
mailing list