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.
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.
On 5/2/2016 1:48 PM, João Santos wrote:
I think the ".d = 1" statement feels like a bug waiting to happen. It's very easy to miss a dot.
On 2 May 2016 at 09:34, Robert van Geel <firstname.lastname@example.org> wrote:
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.On 5/2/2016 5:28 AM, Franklin? Lee wrote:
On Sun, May 1, 2016 at 4:27 PM, Robert van Geel <email@example.com> wrote:
First of all I'm new to this. I tried figuring out if some inquiry like mineWould the following solve your usecase? Explicit naming:
below already was posted but I couldn't find it, frankly partly because I
don't know what to look for, I'm not sure if there's a name for this idea.
I'm not convinced my idea below is solid so apologies if it's naïve but I
figured to post it anyway.
It has to do with the possibility to fold typical opcodes pairs by
introducing a language construct.
The idea is to be able to write this code:
myobject.d = 1
.d = 1
with myobject import a,b,c,d:
d = 1
Alternatively, putting the object at the end (like in gen expressions):
with a,b,c,d from myobject:
d = 1
* Should this add additional scope?
* Descriptors and `__getattr__`-only attributes: Do you get the
attribute at the start of the block, or do you call `__getattr__`
* That `d = 1` is Pythonically odd if it works as in the original example.
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.
To answer you questions:
- No it would not add scope, it's just a combination of syntactical sugar combined with faster opcodes.
- 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
- 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
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/