<br><div class="gmail_quote">On Thu, Jul 22, 2010 at 9:24 AM,  <span dir="ltr">&lt;<a href="mailto:gregory.smith3@sympatico.ca">gregory.smith3@sympatico.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">





<div>
I agree with the idea, but a far less radical change is needed to get the desired result.<br>The basic idea is this: it should be possible to use any name as an identifier in the syntax, including names<br>like &#39;while&#39; and &#39;import&#39;. But there is no need to mess up the entire language to allow this<br>

(either by quoting all the identifiers, perl-style, or by marking the keywords). <br></div></blockquote><div><br></div><div>Yuck.  Anyone who feels they need a variable named the same a reserved word simply feels wrong and needs reeducation.  New words are introduced very rarely and we do care about the ramifications when we do it.</div>

<div><br></div><div>What next?  An optional way to support case insensitive names using a unicode character prefix?</div><div><br></div><div>-gps</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><br>All that is needed is something like this:<br><br>foo = 7<br>:foo = 7   # exactly like foo=7<br>:while= 3  # assigns 3 to variable &#39;while&#39;<br>globals()[&#39;while&#39;]=3  # current way to do this<br><br>

print element.:for  # from example below<br>#<br># keyword parameters to a function call:<br>#<br>BuildUrlQuery( lang=&#39;en&#39;, item=&#39;monsoon&#39;, :class=&#39;normal&#39;)  # -&gt; &quot;?lang=en&amp;query=monsoon&amp;class=normal&quot;<br>

<br><br>The generic keyword function call is a really nice language feature, but it&#39;s rather impaired by the need to avoid<br>those names which happen to be keywords.<br><br>The lack of this is most painful when you are auto-generating python code which forms a bridge to another language with its own<br>

namespace (as in XML example). It&#39;s a pain when some of the names you might generate could conflict with python keywords. <br>So, you end up using dicts and getattrs for everything and the code gets much less readable. With a simple escape like :name available,<br>

it&#39;s worthwhile to do everything with identifiers and generate the escape only as needed for these.<br><br><br>One of the great strengths of python is the ability to form cleans and comprehensive bridges to other languages and environments (thus,<br>

in many cases, avoiding the need to write programs in those other environments :-) ). This feature would fill a gap there.<br><br>The python tcl/tk interface is a bit messed up since tcl/tk uses some 
names for options which conflict with python keywords,<br>
and so you need to add &#39;_&#39; to those names.<br>
<br>There is a feature like this in VHDL:  \name\ and \while\ are identifiers, the backslashes are not part of the name, but just<br>quote it. In  VHDL you can write identifiers like  \22\, and \!This?is=Strange\ as well; since VHDL creates modules that<br>

have named ports, and those modules can interface to things generated by other environments, they needed a<br>way to assign any name to a port.<br><br>For python, I&#39;m not sure it makes sense to allow identifiers that doesn&#39;t follow the basic rule &quot;[A-Za-z_][A-Za-z_0-9]*&quot; -- that could<br>

break some debugging tools which expect variable names to be well-formed -- but it would be useful <br>to be able to use any well-formed name as an identifier, including those which happen to be keywords.<br><br>I&#39;ve suggested :name, which doesn&#39;t break old code, and doesn&#39;t require using any new punctuation. Syntax would not change,<br>

just the lexical definition of &#39;identifier&#39;.  If the intent is to allow arbitrary names (not just well-formed ones), then n&#39;name&#39; would<br>work better (and is consistent with existing stuff).<br><br><br><br>

&gt; Date: Thu, 22 Jul 2010 10:41:39 -0400<br>&gt; From: <a href="mailto:jnoller@gmail.com" target="_blank">jnoller@gmail.com</a><br>&gt; To: <a href="mailto:bartosz-tarnowski@zlotniki.pl" target="_blank">bartosz-tarnowski@zlotniki.pl</a><br>

&gt; CC: <a href="mailto:python-dev@python.org" target="_blank">python-dev@python.org</a><br>&gt; Subject: Re: [Python-Dev] Set the namespace free!<div><div></div><div class="h5"><br>&gt; <br>&gt; On Thu, Jul 22, 2010 at 10:04 AM, Bartosz Tarnowski<br>

&gt; &lt;<a href="mailto:bartosz-tarnowski@zlotniki.pl" target="_blank">bartosz-tarnowski@zlotniki.pl</a>&gt; wrote:<br>&gt; &gt;<br>&gt; &gt; Hello, guys.<br>&gt; &gt;<br>&gt; &gt; Python has more and more reserved words over time. It becomes quite<br>

&gt; &gt; annoying, since you can not use variables and attributes of such names.<br>&gt; &gt; Suppose I want to make an XML parser that reads a document and returns an<br>&gt; &gt; object with attributes corresponding to XML element attributes:<br>

&gt; &gt;<br>&gt; &gt;&gt; elem = parse_xml(&quot;&lt;element param=&#39;boo&#39;/&gt;&quot;)<br>&gt; &gt;&gt; print elem.param<br>&gt; &gt; boo<br>&gt; &gt;<br>&gt; &gt; What should I do then, when the attribute is a reserver word? I could use<br>

&gt; &gt; trailing underscore, but this is quite ugly and introduces ambiguity.<br>&gt; &gt;<br>&gt; &gt;&gt; elem = parse_xml(&quot;&lt;element for=&#39;each&#39;/&gt;&quot;)<br>&gt; &gt;&gt; print elem.for_ #?????<br>&gt; &gt;&gt; elem = parse_xml(&quot;&lt;element for_=&#39;each&#39;/&gt;&quot;)<br>

&gt; &gt;&gt; print elem.for__ #?????<br>&gt; &gt;<br>&gt; &gt; My proposal: let&#39;s make a syntax change.<br>&gt; &gt;<br>&gt; &gt; Let all reserved words be preceded with some symbol, i.e. &quot;!&quot; (exclamation<br>

&gt; &gt; mark). This goes also for standard library global identifiers.<br>&gt; &gt;<br>&gt; &gt; !for boo in foo:<br>&gt; &gt;    !if boo is !None:<br>&gt; &gt;        !print(hoo)<br>&gt; &gt;    !else:<br>&gt; &gt;        !return !sorted(woo)<br>

&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; This would allow the user to declare any identifier with any name:<br>&gt; &gt;<br>&gt; &gt; for = with(return) + try<br>&gt; &gt;<br>&gt; &gt; What do you think of it? It is a major change, but I think Python needs it.<br>

&gt; &gt;<br>&gt; &gt; --<br>&gt; &gt; haael<br>&gt; &gt;<br>&gt; <br>&gt; I&#39;m not a fan of this - I&#39;d much prefer[1] that we use the exclamation<br>&gt; point to determine scope:<br>&gt; <br>&gt; foobar - local<br>

&gt; !foobar - one up<br>&gt; !!foobar - higher than the last one<br>&gt; !!!foobar - even higher in scope<br>&gt; <br>&gt; We could do the inverse as well; if you append ! you can push variable<br>&gt; down in scope.<br>

&gt; <br>&gt; Jesse<br>&gt; <br>&gt; <br>&gt; [1] I am not serious.<br>&gt; _______________________________________________<br>&gt; Python-Dev mailing list<br>&gt; <a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>

&gt; <a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br></div></div>&gt; Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/gsmith%40alumni.uwaterloo.ca" target="_blank">http://mail.python.org/mailman/options/python-dev/gsmith%40alumni.uwaterloo.ca</a><br>

                                               </div>
<br>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/greg%40krypto.org" target="_blank">http://mail.python.org/mailman/options/python-dev/greg%40krypto.org</a><br>
<br></blockquote></div><br>