Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63254
| Newsgroups | comp.lang.python |
|---|---|
| Subject | Re: Postfix conditionals |
| References | <mailman.4966.1388953508.18130.python-list@python.org> |
| From | "Rhodri James" <rhodri@wildebst.org.uk> |
| Organization | The Wildebestiary |
| Message-ID | <op.w88r80z25079vu@gnudebeest> (permalink) |
| Date | 2014-01-06 01:40 +0000 |
On Sun, 05 Jan 2014 20:24:53 -0000, Göktuğ Kayaalp <self@gkayaalp.com> wrote: > AFAIK, we do not have "postfix conditionals" in Python, i.e. a condition > appended to a statement, which determines whether the statement runs or > not: > py> for i in [False]: > ... break if not i > The above piece of code is equivalent to this in Python: > py> for i in [False]: > ... if not i > ... break > I believe that the first example is superior to the second example when > the two is compared for readability and intuitiveness. In my past life as a newcomer to Perl, I thought this too. Postfix conditionals read more like English, so they would be easier to take in and understand. As I wrote more code, I discovered that this didn't seem to be the case; except in very simple cases, I had to mentally transpose the conditional back to the start of the statement to properly comprehend what was going on and what the results would be for my sample data. It looks like a good idea, but I don't think it works that well in practice. -- Rhodri James *-* Wildebeest Herder to the Masses
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Postfix conditionals Göktuğ Kayaalp <self@gkayaalp.com> - 2014-01-05 22:24 +0200
Re: Postfix conditionals Roy Smith <roy@panix.com> - 2014-01-05 15:41 -0500
Re: Postfix conditionals Göktuğ Kayaalp <self@gkayaalp.com> - 2014-01-05 22:54 +0200
Re: Postfix conditionals Dan Stromberg <drsalists@gmail.com> - 2014-01-05 13:08 -0800
Re: Postfix conditionals "Rhodri James" <rhodri@wildebst.org.uk> - 2014-01-06 01:40 +0000
Re: Postfix conditionals Göktuğ Kayaalp <self@gkayaalp.com> - 2014-01-06 09:51 +0200
Re: Postfix conditionals "Rhodri James" <rhodri@wildebst.org.uk> - 2014-01-07 00:48 +0000
Re: Postfix conditionals "BartC" <bc@freeuk.com> - 2014-02-03 23:43 +0000
Re: Postfix conditionals Göktuğ Kayaalp <self@gkayaalp.com> - 2014-02-04 07:16 +0200
Re: Postfix conditionals "BartC" <bc@freeuk.com> - 2014-02-04 10:00 +0000
Re: Postfix conditionals Chris Angelico <rosuav@gmail.com> - 2014-02-04 16:23 +1100
csiph-web