[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Stephen J. Turnbull
Chris Angelico writes: > Then I completely don't understand getself. Can you give an example > of how it would be used? So far, it just seems like an utter total > mess. It's possible that __getself__ would be implemented "halfway". That is, if __getself__ is present, it is invoked, and

[Python-ideas] Code is a social construct [was: A proposal (and implementation) ...]

2019-06-26 Thread Stephen J. Turnbull
Anders Hovmöller writes: > In python code basically can't be understood at face value. Not really a problem. The #ToddlerInChief doesn't code; the rest of us are adults and use code by consent. Obfuscate your code by seriously violating the expections for the meaning of "+" or ".denominator"

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread nate lust
:Hello all, I am sorry to send this out to the list and then be so silent, work and children and all. I am going to try and address the issues raised in this thread, with apologies if I miss someones issue. Some of these are addressed in the documentation I wrote, but I know I can't expect people

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Brendan Barnwell
On 2019-06-26 14:27, nate lust wrote: This is the example I was talking about specifically: https://github.com/natelust/CloakingVarWriteup/blob/master/examples.py#L76. There are other possibilities as well, I would be happy to explain my Ideas directly, I am not sure exactly everything Yanghao

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Andrew Barnert via Python-ideas
On Jun 26, 2019, at 15:46, Greg Ewing wrote: > > Yes, but it's pretty universal across languages with name-binding > semantics for assignment (Lisp, Ruby, Javascript etc.) that assigning > to a local name doesn't invoke any magic. I don’t think that’s quite true. Many languages with

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Greg Ewing
Yanghao Hua wrote: when you do x.y = z and if y is a descriptor you don't expect x.y is now pointing/binding to z, you have to understand the object behavior anyway. I do not see how this is different in the set/getself() case. The difference is that the special behaviour is associated with

[Python-ideas] Parsing strings with Python (was Re: Re: Proposal: Using % sign for percentage)

2019-06-26 Thread Chris Angelico
Please change the subject line when you change the topic of conversation. Or even better, since this isn't strongly related to what you're replying to, and you quoted no text whatsoever - just make it a brand new post. Thanks! On Thu, Jun 27, 2019 at 5:06 AM James Lu wrote: > > What if we had

[Python-ideas] Re: Proposal: Using % sign for percentage

2019-06-26 Thread Andrew Barnert via Python-ideas
On Jun 25, 2019, at 08:44, James Lu wrote: > > What if we had reverse format strings, i.e. reading formatted input? > > x = readf("{:.0%}", "50%") > # => x == 0.50 > x = readf("{:.0}", "50") > # => x == 0.50 > > Readf takes the repr() of its second argument and “un-formats” the string. What’s

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Greg Ewing
Anders Hovmöller wrote: On 26 Jun 2019, at 16:46, Chris Angelico wrote: it violates programmer expectations *across many languages* regarding refactoring. isn't that potentially extremely different in C++ for example? Yes, but it's pretty universal across languages with name-binding

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Andrew Barnert via Python-ideas
On Jun 26, 2019, at 13:53, Chris Angelico wrote: > Then in what circumstances will getself NOT be called? What is the > point of having an object, if literally every reference to it will > result in something else being used? I think Yanghao has misunderstood the proposal. What Nate actually

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Andrew Barnert via Python-ideas
On Wednesday, June 26, 2019, 11:53:30 AM PDT, Chris Angelico wrote: > I don't think you can define what "f->spam" means Well, you can, but only the first half of what it means, so I don't think this changes your point. If f is a pointer, then f->spam means to dereference the pointer f, then

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Yanghao Hua
On Wed, Jun 26, 2019 at 11:24 PM nate lust wrote: [...] > Yanhao, I do not think you are doing this proposal any good. I appreciate you > trying to go to bat for it, but there are many good concerns here that would > be good to hear out and address rather than trying to dismiss them. I was

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Yanghao Hua
On Wed, Jun 26, 2019 at 11:16 PM Chris Angelico wrote: [...] > Then I completely don't understand getself. Can you give an example of > how it would be used? So far, it just seems like an utter total mess. Sure, below is my code snippet for signal get/set, using "L[:] = thing" syntax and

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread nate lust
This is the example I was talking about specifically: https://github.com/natelust/CloakingVarWriteup/blob/master/examples.py#L76. There are other possibilities as well, I would be happy to explain my Ideas directly, I am not sure exactly everything Yanghao is saying as I have not been able to

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread nate lust
Chris, There are a lot of messages for me to catch up on from today, but I am heading home from work, and your most recent one is the easiest to address quickly. I want to start out by saying I agree with many of the objections and concerns raised here, and there were some I had not thought

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Chris Angelico
On Thu, Jun 27, 2019 at 7:11 AM Yanghao Hua wrote: > > On Wed, Jun 26, 2019 at 11:00 PM Chris Angelico wrote: > > > > On Thu, Jun 27, 2019 at 6:50 AM Yanghao Hua wrote: > > > > > > On Wed, Jun 26, 2019 at 10:16 PM Chris Angelico wrote: > > > > > > > > Let's suppose that frob() returns

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Yanghao Hua
On Wed, Jun 26, 2019 at 11:00 PM Chris Angelico wrote: > > On Thu, Jun 27, 2019 at 6:50 AM Yanghao Hua wrote: > > > > On Wed, Jun 26, 2019 at 10:16 PM Chris Angelico wrote: > > > > > > Let's suppose that frob() returns something that has a __getself__ > > > method. Will f1 trigger its call?

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Chris Angelico
On Thu, Jun 27, 2019 at 6:50 AM Yanghao Hua wrote: > > On Wed, Jun 26, 2019 at 10:16 PM Chris Angelico wrote: > > > > Let's suppose that frob() returns something that has a __getself__ > > method. Will f1 trigger its call? Will f2? If the answer is "yes" to > > both, then when ISN'T getself

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Andrew Barnert via Python-ideas
On Jun 26, 2019, at 07:34, Anders Hovmöller wrote: > > I 100% agree that this proposal is a bad idea. But I do have to play Devils > advocate here. > > The the-code-is-understandable-at-face-value ship has already sailed. + > doesn't mean add, it means calling a dunder function that can do

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Yanghao Hua
On Wed, Jun 26, 2019 at 10:16 PM Chris Angelico wrote: > > On Thu, Jun 27, 2019 at 5:29 AM Yanghao Hua wrote: > > > > On Wed, Jun 26, 2019 at 4:47 PM Chris Angelico wrote: > > [...] > > > There are many things that can be implemented with dunders, yes, but > > > in Python, I would expect these

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Ethan Furman
On 06/26/2019 07:34 AM, Anders Hovmöller wrote: I 100% agree that this proposal is a bad idea. But I do have to play Devils advocate here. The the-code-is-understandable-at-face-value ship has already sailed. + doesn't mean add, it means calling a dunder function that can do anything.

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Chris Angelico
On Thu, Jun 27, 2019 at 5:29 AM Yanghao Hua wrote: > > On Wed, Jun 26, 2019 at 4:47 PM Chris Angelico wrote: > [...] > > There are many things that can be implemented with dunders, yes, but > > in Python, I would expect these two functions to behave identically: > > > > def f1(x): > > return

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Yanghao Hua
On Wed, Jun 26, 2019 at 4:47 PM Chris Angelico wrote: [...] > There are many things that can be implemented with dunders, yes, but > in Python, I would expect these two functions to behave identically: > > def f1(x): > return frob(x).spam > > def f2(x): > f = frob(x) > s = f.spam >

[Python-ideas] Re: Proposal: Using % sign for percentage

2019-06-26 Thread James Lu
What if we had reverse format strings, i.e. reading formatted input? x = readf("{:.0%}", "50%") # => x == 0.50 x = readf("{:.0}", "50") # => x == 0.50 Readf takes the repr() of its second argument and “un-formats” the string. ___ Python-ideas mailing

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Chris Angelico
On Thu, Jun 27, 2019 at 1:41 AM Anders Hovmöller wrote: > > On 26 Jun 2019, at 16:46, Chris Angelico wrote: > > There are many things that can be implemented with dunders, yes, but > > in Python, I would expect these two functions to behave identically: > > > > def f1(x): > >return

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading (was: (Re: Re: Overloading assignment concrete proposal (Re: Re: Operator as first class citizens -- like in s

2019-06-26 Thread nate lust
Stephen, Thanks for the reply, it is a busy day at work today, so it is going to take me a little bit of time to sit down and really process all you have said. I wanted to drop you a message though and link you to the examples that I mentioned.

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Anders Hovmöller
> On 26 Jun 2019, at 16:46, Chris Angelico wrote: > >> On Thu, Jun 27, 2019 at 12:37 AM Anders Hovmöller >> wrote: >> On 26 Jun 2019, at 14:28, Rhodri James wrote: On 26/06/2019 08:34, Yanghao Hua wrote: I find the objection reasoning very strange as none of the

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Chris Angelico
On Thu, Jun 27, 2019 at 12:37 AM Anders Hovmöller wrote: > > > On 26 Jun 2019, at 14:28, Rhodri James wrote: > > > >> On 26/06/2019 08:34, Yanghao Hua wrote: > >> I find the objection reasoning very strange as none of the default > >> behavior changed, and yet if you use this feature you do need

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Anders Hovmöller
> On 26 Jun 2019, at 14:28, Rhodri James wrote: > >> On 26/06/2019 08:34, Yanghao Hua wrote: >> I find the objection reasoning very strange as none of the default >> behavior changed, and yet if you use this feature you do need to worry >> about the object behavior regarding assignment, this

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading

2019-06-26 Thread Rhodri James
On 26/06/2019 08:34, Yanghao Hua wrote: I find the objection reasoning very strange as none of the default behavior changed, and yet if you use this feature you do need to worry about the object behavior regarding assignment, this is true for descriptors and all other magics. The problem is

[Python-ideas] Re: A proposal (and implementation) to add assignment and LOAD overloading (was: (Re: Re: Overloading assignment concrete proposal (Re: Re: Operator as first class citizens -- like in s

2019-06-26 Thread Yanghao Hua
On Tue, Jun 25, 2019 at 11:01 PM nate lust wrote: > > This message is related to two previous threads, but was a sufficiently > evolved to warrant a new topic. > > I am proposing that two new magic methods be added to python that will > control assignment and loading of class > instances. This

[Python-ideas] A proposal (and implementation) to add assignment and LOAD overloading (was: (Re: Re: Overloading assignment concrete proposal (Re: Re: Operator as first class citizens -- like in scala

2019-06-26 Thread Stephen J. Turnbull
nate lust writes: > On first read, that may be surprising, but it extends a behavior > pattern that already exists for things like properties (and > generically descriptors) to object instances themselves. I don't think that's a correct interpretation. In all cases of assignment, a name is