Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69256

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

From Peter Otten <__peter__@web.de>
Subject Re: Python language hack for C-style programmers [DO NOT USE!] :-)
Date 2014-03-28 09:26 +0100
Organization None
References (1 earlier) <CAPTjJmoSEiBEO9fXfwM7mGywty+dT8erBqeu2mpyrxAf12udcw@mail.gmail.com> <lh2jsg$cqu$1@ger.gmane.org> <CAPTjJmoU-Aa_Y2DDHzCyzMNUfNnuV2i2gsHWZP3gKBhzrXjLzw@mail.gmail.com> <lh39cc$6cd$1@ger.gmane.org> <CAPTjJmrXbB+3sK9BBg-PMik0wFB0XpzzqbidL1r1qUuuSNa2fQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.8660.1395995177.18130.python-list@python.org> (permalink)

Show all headers | View raw


Chris Angelico wrote:

> On Fri, Mar 28, 2014 at 6:46 PM, Peter Otten <__peter__@web.de> wrote:
>> Why would you guess if you can check? Just fire up the interactive
>> interpreter^W^W compiler:
> 
> Partly because there's a difference between valid C++ and valid input
> to the G++ compiler :) Knowing that it works with g++ doesn't tell me
> that it's actually valid, and I don't feel like digging into the specs
> to find out where you're guaranteed to be allowed to do that. (I could
> probably test it with one of the language spec options, but then it
> still depends on the exact version of GCC and the exact spec chosen.)

I don't have the spec handy, only an old copy of "The C++ Programming 
Language" which has

"""
To avoid accidental misuse of a variable, it is usually a good idea to 
introduce the variable into the smallest scope possible [and] to delay the 
definition of a local variable until one can give it an initial value.
[...] 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;
}
"""

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python language hack for C-style programmers [DO NOT USE!] :-) Peter Otten <__peter__@web.de> - 2014-03-28 09:26 +0100

csiph-web