Python language hack for C-style programmers [DO NOT USE!] :-)

Chris Angelico rosuav at gmail.com
Fri Mar 28 04:38:52 EDT 2014


On Fri, Mar 28, 2014 at 7:26 PM, Peter Otten <__peter__ at web.de> wrote:
> One of the most elegant applications of these two principles is to
> declare a variable in a condition. Consider:
>
> if (double d = prim(true)) {
>     left /= d;
>     break;
> }

Okay! Then I withdraw the "or, to my knowledge, C++" part of my
original statement. It's a useful feature, if not a unique one.

ChrisA



More information about the Python-list mailing list