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


Groups > comp.lang.python > #28927

Re: Double sided double underscored variable names

Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'example:': 0.03; 'argument': 0.04; 'compiler': 0.05; 'say,': 0.05; '#define': 0.07; 'converts': 0.07; 'function,': 0.07; 'semantic': 0.07; 'python': 0.09; 'lost.': 0.09; 'macros': 0.09; 'optimizing': 0.09; 'received:mail-vc0-f174.google.com': 0.09; 'sep': 0.09; 'through.': 0.09; 'language': 0.14; 'do,': 0.15; 'languages.': 0.15; 'ah,': 0.16; 'constants': 0.16; 'doing,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'in-line': 0.16; 'macros.': 0.16; 'silly': 0.16; 'subject:variable': 0.16; 'twice.': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'instance,': 0.17; 'tend': 0.17; '(in': 0.18; 'question.': 0.20; 'meant': 0.21; 'dropped': 0.22; 'posts': 0.23; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'guess': 0.27; 'separate': 0.27; 'c++': 0.27; 'functions.': 0.27; 'in.': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'lines': 0.28; 'chris': 0.28; 'post': 0.28; "d'aprano": 0.29; 'overhead': 0.29; 'received:209.85.220.174': 0.29; 'steven': 0.29; 'definition': 0.29; 'handled': 0.29; 'no,': 0.29; 'probably': 0.29; "i'm": 0.29; 'maybe': 0.29; 'evaluation': 0.30; 'keyword': 0.30; 'function': 0.30; 'sense': 0.31; 'gets': 0.32; 'could': 0.32; 'getting': 0.33; 'int': 0.33; 'problem': 0.33; 'to:addr :python-list': 0.33; 'knowledge': 0.33; 'languages': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'along': 0.35; 'posting': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'add': 0.36; 'but': 0.36; 'wanted': 0.36; '12,': 0.36; "i'll": 0.36; 'address.': 0.36; 'being': 0.37; 'previous': 0.37; 'received:209': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'some': 0.38; 'things': 0.38; 'performance': 0.39; 'to:addr:python.org': 0.39; 'apply': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'your': 0.60; 'most': 0.61; 'side': 0.61; "you'll": 0.62; 'email addr:python.org.': 0.62; 'email name:python-list': 0.62; 'repeat': 0.62; 'solve': 0.62; 'day.': 0.63; 'more': 0.63; 'fun': 0.64; 'differences': 0.65; 'wanting': 0.65; 'fact,': 0.69; 'overhead,': 0.84; 'valid,': 0.84; 'write:': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=I8iUAGE8G1pDaoyicftH1+fPkput37Y1xPUqF6Jg3Os=; b=dEEyGpbHIkqq+nva0eiItqF3fdrrNBN+ybV9JzQH9+2uT01jZbN6X0EAv/G28xdKNF ype8+zQ0lcfRFW6QmejXFcvpdpaVOSMsHL498aZQ3jwXKz8/ZHFU4tbuKpv1rDovI9Xg 3EBMG0TjvrRngKrJN2RqgNj2aYKsA5Lqk2VWMIxM5SuNGatV4GnhjIVDWW7WsOqChp9y nq+s6tEpAnYWMhOVoxr2+228T09BlsHJbxVL44Fe4z0DKtKnLXJ/oBPn+LI22pjzB8/G ke3S3Q+4EWpSACtfY2l0JrKzYYTQG5LXnWMpi/1miWp1hBGSkeusWMcNsUgdLKkWibgE L6Kg==
MIME-Version 1.0
In-Reply-To <CAN1F8qW_3r5X9cDC_CF3QSTL0zRn4S9YX=30vduU8aU+aSN-3A@mail.gmail.com>
References <CAN1F8qXpeHAQGJG9urY2NjL_01gX++cMhkgiD3mt3nZsYzYcJQ@mail.gmail.com> <CAPTjJmqh8V9kZm3bQ-BHGDc-qsEuxykh8DCg4s3z5x+JcxW-WA@mail.gmail.com> <CAN1F8qUuXho43hPdGKyh3sAyZHx7JegFfSEU+JhqwyA552a=DA@mail.gmail.com> <mailman.526.1347403933.27098.python-list@python.org> <504fe1e7$0$29981$c3e8da3$5496439d@news.astraweb.com> <CAN1F8qW_3r5X9cDC_CF3QSTL0zRn4S9YX=30vduU8aU+aSN-3A@mail.gmail.com>
Date Wed, 12 Sep 2012 14:12:20 +1000
Subject Re: Double sided double underscored variable names
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.536.1347423143.27098.python-list@python.org> (permalink)
Lines 66
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1347423143 news.xs4all.nl 6901 [2001:888:2000:d::a6]:50491
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28927

Show key headers only | View raw


On Wed, Sep 12, 2012 at 11:38 AM, Joshua Landau
<joshua.landau.ws@gmail.com> wrote:
> On 12 September 2012 02:14, Steven D'Aprano
> <steve+comp.lang.python@pearwood.info> wrote:
>>
>> And again, Joshua's original post is not available from my provider.
>> Joshua, I suspect that something about your post is being seen as spam
>> and dropped by at least some providers.
>
> I am sorry to ask this, but in the meantime can someone who isn't
> spam-filtered repost my messages? I'll give them a cookie!
> To repeat my previous post, I'm using GMail and posting to
> python-list@python.org. If that is what I'm meant to be doing, I'll try
> another email address.

Mailing to python-list@python from Gmail is exactly what I do, and far
as I know, none of my posts are getting lost. But then, I'm seeing all
your posts, too, so maybe I just don't know when my posts don't go
through.

>> On Wed, 12 Sep 2012 08:52:10 +1000, Chris Angelico wrote:
>>
>> > Inline functions? I like this idea. I tend to want them in pretty much
>> > any language I write in.
>>
>> What do you mean by in-line functions? If you mean what you literally
>> say, I would answer that Python has that with lambda.
>>
>> But I guess you probably mean something more like macros.
>
> No, just multi-line lambda. Macros, if my knowledge of lower-level languages
> is valid, would be sorta' silly in Python.

Ah, okay. I was thinking more along the lines of what you call macros,
but in the C++ sense of inline functions. In C, macros are handled at
precompilation stage, and are dangerous. Classic example:

#define squared(x) x*x

x_squared = squared(6+7)

So your macros end up littered with parentheses, and it still doesn't
solve anything, as the argument still gets evaluated twice. (A problem
if it has side effects - eg if it's a function call.)

What I'm thinking of, though, is like C++ functions. You can put the
'inline' keyword onto any function, and the compiler will do its best
to inline it (in fact, a good optimizing compiler will inline things
regardless, but that's a separate point). I can write:

inline int squared(int x) {return x*x;}

and C++ will add no function overhead, but will still do all the
proper evaluation order etc.

Of course, C++ doesn't allow monkeypatching, so you'll never have
semantic differences from inlining. It's just a performance question.
But I use inline functions like constants - for instance, I could
create a function that converts a database ID into an internal
reference number, and I can change the definition of that function in
one place and have it apply everywhere, just like if I wanted to
change the definition of math.PI to 3.142857 for fun one day. Of
course I can use a normal (out-of-line) function for this, but that
has overhead in most languages. Hence, wanting inline functions.

ChrisA

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


Thread

Re: Double sided double underscored variable names Chris Angelico <rosuav@gmail.com> - 2012-09-12 08:52 +1000
  Re: Double sided double underscored variable names Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-12 01:14 +0000
    Re: Double sided double underscored variable names Chris Angelico <rosuav@gmail.com> - 2012-09-12 14:12 +1000
    Re: Double sided double underscored variable names Joshua Landau <joshua.landau.ws@gmail.com> - 2012-09-12 10:55 +0100

csiph-web