<p dir="ltr">That is matter of experience, I already lost too many hours of my life looking for weird bugs caused by misspellings and missing commas, and I don't even work with people new to python. </p>
<div class="gmail_quote">On 2 May 2016 14:04, "Robert van Geel" <<a href="mailto:robert@bign.nl">robert@bign.nl</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
That's a matter of perception. As said this syntax was implemented
and used for a long time in another (now obsolete) language (visual
foxpro) and there it never led to confusion or errors nor have I
ever heard such complaints from any other user in that community.
For Python developers, since this is a yet unfamiliar syntax, this
might look unfamiliar and hence rejectable.<br>
<br>
<div>On 5/2/2016 1:48 PM, João Santos wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr"><span style="font-size:12.8px">I think the ".d = 1"
statement feels like a bug waiting to happen. It's very easy
to miss a dot.</span><br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 2 May 2016 at 09:34, Robert van Geel
<span dir="ltr"><<a href="mailto:robert@bign.nl" target="_blank">robert@bign.nl</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div>On 5/2/2016 5:28 AM, Franklin? Lee wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Sun, May 1, 2016 at 4:27 PM, Robert van Geel <<a href="mailto:robert@bign.nl" target="_blank"><a href="mailto:robert@bign.nl" target="_blank">robert@bign.nl</a></a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
First of all I'm new to this. I tried figuring out
if some inquiry like mine<br>
below already was posted but I couldn't find it,
frankly partly because I<br>
don't know what to look for, I'm not sure if there's
a name for this idea.<br>
I'm not convinced my idea below is solid so
apologies if it's naïve but I<br>
figured to post it anyway.<br>
It has to do with the possibility to fold typical
opcodes pairs by<br>
introducing a language construct.<br>
<br>
The idea is to be able to write this code:<br>
<br>
myobject.a<br>
myobject.b<br>
myobject.c()<br>
myobject.d = 1<br>
<br>
like this:<br>
<br>
using myobject:<br>
.a<br>
.b<br>
.c()<br>
.d = 1<br>
</blockquote>
Would the following solve your usecase? Explicit
naming:<br>
<br>
with myobject import a,b,c,d:<br>
a<br>
b<br>
c()<br>
d = 1<br>
<br>
<br>
Alternatively, putting the object at the end (like in
gen expressions):<br>
<br>
with a,b,c,d from myobject:<br>
a<br>
b<br>
c()<br>
d = 1<br>
<br>
<br>
Questions:<br>
* Should this add additional scope?<br>
* Descriptors and `__getattr__`-only attributes:
Do you get the<br>
attribute at the start of the block, or do you call
`__getattr__`<br>
every time?<br>
* That `d = 1` is Pythonically odd if it works as
in the original example.<br>
</blockquote>
<br>
</div>
</div>
Sidenote: the idea I posed is actually borrowed from a
language i used to use, Visual Foxpro, where it was
implemented using the 'with' keyword.<br>
<br>
Your proposal has the need to duplicate all variables, so
instead of multiple times typing "self." you have to type
them double in the line using "with" so it's shorter but not
optimally short. Also if you want the accompanying faster
opcodes that means you have to put 4 variables on the stack
straight away for fast access, instead of one.<br>
<br>
To answer you questions:<br>
- No it would not add scope, it's just a combination of
syntactical sugar combined with faster opcodes.<br>
- The attributes are not grabbed at the beginning of the
block, instead internally in memory there's a 'grabbed
object' stack that can be accessed directly without the
LOAD_FAST opcode<br>
- Your fourth remarks refers to your non-dotted code. I
think the ".d = 1" statement feels pythonic but again maybe
because I was so used to the syntax in the VFP language
<div>
<div><br>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a></div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</blockquote></div>