On Sun, May 1, 2016 at 4:27 PM, Robert van Geel <robert@bign.nl> wrote:
First of all I'm new to this. I tried figuring out if some inquiry like mine 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.a myobject.b myobject.c() myobject.d = 1
like this:
using myobject: .a .b .c() .d = 1
Would the following solve your usecase? Explicit naming: with myobject import a,b,c,d: a b c() d = 1 Alternatively, putting the object at the end (like in gen expressions): with a,b,c,d from myobject: a b c() d = 1 Questions: * 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__` every time? * That `d = 1` is Pythonically odd if it works as in the original example.