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


Groups > comp.lang.python > #7999

Re: What is this syntax ?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'from:addr:libero.it': 0.07; 'dict': 0.09; 'host,': 0.09; 'port,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:libero.it': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'wrote:': 0.14; 'defined': 0.14; 'roy': 0.16; 'subject:syntax': 0.16; 'skip:" 40': 0.16; 'right,': 0.22; 'asked': 0.24; 'code': 0.24; '(and': 0.25; "i'm": 0.27; 'modifying': 0.30; 'strings,': 0.30; 'print': 0.31; 'steven': 0.32; 'header:X-Complaints-To:1': 0.32; 'to:addr:python-list': 0.33; 'php': 0.34; 'that,': 0.34; 'header:User-Agent:1': 0.35; "d'aprano": 0.35; 'subject: ?': 0.35; 'subject:What': 0.35; 'think': 0.38; 'received:org': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'feature': 0.40; 'format': 0.40; 'touch': 0.65; 'direct': 0.65; 'received:151': 0.67; 'route': 0.67; 'learned': 0.73; 'subject:this': 0.76; 'dict,': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Vito 'ZeD' De Tullio <zak.mc.kraken@libero.it>
Subject Re: What is this syntax ?
Followup-To gmane.comp.python.general
Date Mon, 20 Jun 2011 07:42:45 +0200
References <4dfdfc99$0$715$426a34cc@news.free.fr> <4dfe10d1$0$28053$426a34cc@news.free.fr> <roy-2A6DC8.11394419062011@news.panix.com> <e724fc3e-8198-4fb7-b1d3-96834f3fa6bb@34g2000pru.googlegroups.com> <roy-DD0C35.16204819062011@news.panix.com> <mailman.164.1308517611.1164.python-list@python.org> <4dfe841c$0$30002$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host ppp-14-21.26-151.libero.it
User-Agent KNode/4.4.11
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.169.1308548598.1164.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 82.94.164.166
X-Trace 1308548598 news.xs4all.nl 49045 [::ffff:82.94.164.166]:48420
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7999

Followups directed to: gmane.comp.python.general

Show key headers only | View raw


Steven D'Aprano wrote:

>> and you can achieve php interpolation via locals()
>> 
>>>>> a = 'b'
>>>>> print("%(a)s" % locals())
>> b
> 
> You can do that, but when reading code I consider any direct use of
> locals() (and globals() for that matter) to be a code smell:

well you're right, me neither like very much to touch locals() and (worse) 
globals(), but

1) this is the "php interpolation" Roy Smith asked for: 
       print "$scheme://$host:$port/$route#$fragment"
   where are defined scheme, host, port, route and fragment?
   or you think also this is "code smell"?

2) I'm in no way modifying the dict, just accessing in read only.

3) I'm restricting to locals() :D


btw I never used dict to format strings, so I learned how old this feature 
is :D

-- 
By ZeD

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


Thread

What is this syntax ? candide <candide@free.invalid> - 2011-06-19 15:41 +0200
  Re: What is this syntax ? Laurent Claessens <moky.math@gmail.com> - 2011-06-19 15:50 +0200
  Re: What is this syntax ? Noah Hall <enalicho@gmail.com> - 2011-06-19 14:58 +0100
  Re: What is this syntax ? Chris Angelico <rosuav@gmail.com> - 2011-06-20 00:03 +1000
  Re: What is this syntax ? candide <candide@free.invalid> - 2011-06-19 17:08 +0200
    Re: What is this syntax ? Roy Smith <roy@panix.com> - 2011-06-19 11:39 -0400
      Re: What is this syntax ? rusi <rustompmody@gmail.com> - 2011-06-19 09:58 -0700
        Re: What is this syntax ? Roy Smith <roy@panix.com> - 2011-06-19 16:20 -0400
          Re: What is this syntax ? Vito 'ZeD' De Tullio <zak.mc.kraken@libero.it> - 2011-06-19 23:06 +0200
            Re: What is this syntax ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-19 23:19 +0000
              Re: What is this syntax ? Vito 'ZeD' De Tullio <zak.mc.kraken@libero.it> - 2011-06-20 07:42 +0200
          Re: What is this syntax ? Benjamin Kaplan <benjamin.kaplan@case.edu> - 2011-06-19 15:29 -0700

csiph-web