Re: [Python-ideas] Run length encoding

2017-06-18 Thread David Mertz
As an only semi-joke, I have created a module on GH that meets the needs of this discussion (using the spelling I think are most elegant): https://github.com/DavidMertz/RLE On Sun, Jun 11, 2017 at 1:53 AM, Serhiy Storchaka wrote: > 11.06.17 09:17, Neal Fultz пише: > >>* other people have be

Re: [Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread Alireza Rafiei
Thanks for the explanation! On Sun, Jun 18, 2017 at 4:00 PM, Chris Angelico wrote: > On Mon, Jun 19, 2017 at 8:47 AM, Alireza Rafiei > wrote: > >> Hmm. So... after x = f, f.__name__ would be different from x.__name__? > > > > > > Yes. > > There's a couple of major problems with that. The firs

Re: [Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread Chris Angelico
On Mon, Jun 19, 2017 at 8:47 AM, Alireza Rafiei wrote: >> Hmm. So... after x = f, f.__name__ would be different from x.__name__? > > > Yes. There's a couple of major problems with that. The first is that, in Python, there is *absolutely no difference* between accessing an object via one form an

Re: [Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread Alireza Rafiei
> > [snip] > That's not correct. > Look at the definition of 'itername'. The lambda returns the result of > name(x), which is 'x'. > Therefore, the correct result is: > 'x' > 'x' > 'x' > 'x' You're absolutely right! It should be changed to: >>> def itername(collection): > >>> for i in map(na

Re: [Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread Chris Angelico
On Mon, Jun 19, 2017 at 8:16 AM, Alireza Rafiei wrote: > I guess I should have framed it as a `quote` for python. You're absolutely > right that it shouldn't be modifying the assigned object and it doesn't. I > mentioned the Assign to say that in `x = f`, `x` has name as well, however > `x.__name_

Re: [Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread MRAB
On 2017-06-18 22:38, Alireza Rafiei wrote: Hi all, I'm not sure whether this idea has been discussed before or not, so I apologize in advanced if that's the case. Consider the behavior: >>> f = lambda: True >>> f.__name__ '' >>> x = f >>> x.__name__ '' I'm argui

Re: [Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread Alireza Rafiei
The __name__ of a function has nothing to do with an Assign node, > which is simply assigning a value to something. For instance, if you > do: > >>> f = "hello" > you wouldn't expect the string "hello" to have a __name__ - it's just > a string. And a lambda function normally won't be assigned to

Re: [Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread Chris Angelico
On Mon, Jun 19, 2017 at 7:38 AM, Alireza Rafiei wrote: > I'm not sure whether this idea has been discussed before or not, so I > apologize in advanced if that's the case. > > Consider the behavior: > >> >>> f = lambda: True >> >>> f.__name__ >> '' >> >>> x = f >> >>> x.__name__ >> '' > > > I'm arg

[Python-ideas] Continuation of `__name__` or a builtin function for general name getting

2017-06-18 Thread Alireza Rafiei
Hi all, I'm not sure whether this idea has been discussed before or not, so I apologize in advanced if that's the case. Consider the behavior: >>> f = lambda: True > >>> f.__name__ > '' > >>> x = f > >>> x.__name__ > '' I'm arguing the behavior above is too brittle/limited and, considering tha

Re: [Python-ideas] ImportError raised for a circular import

2017-06-18 Thread Oleg Broytman
On Sun, Jun 18, 2017 at 07:21:21PM +0100, Barry Scott wrote: > I was going to simply keep track of the names of the modules that are being > imported > and raise an exception if an import attempted to import a module that had not > completed > being imported. Please don't do that. In SQLObj

Re: [Python-ideas] ImportError raised for a circular import

2017-06-18 Thread Barry Scott
> On 18 Jun 2017, at 19:21, Barry Scott wrote: > >> >> On 14 Jun 2017, at 07:33, Nick Coghlan > > wrote: >> >> On 14 June 2017 at 13:02, Mahmoud Hashemi > > wrote: >>> That would be amazing! If there's anything I can do to help make that >

Re: [Python-ideas] ImportError raised for a circular import

2017-06-18 Thread Mahmoud Hashemi
Barry, that kind of circular import is actually fine in many (if not most) cases. Modules are immediately created and importable, thenincrementally populated. The problem arises when you try to do something with contents of the module that have not been populated, usually manifesting in the Attribu

Re: [Python-ideas] Restore the __members__ behavior to python3 for C extension writers

2017-06-18 Thread Barry Scott
> On 16 Jun 2017, at 09:46, Nick Coghlan wrote: > > On 16 June 2017 at 07:44, Barry Scott wrote: >> But I need the result of __dir__ for my object not its base. Then I need to >> add in the list of member attributes that are missing because python >> itself has no knowledge of them they are acc

Re: [Python-ideas] ImportError raised for a circular import

2017-06-18 Thread Barry Scott
> On 14 Jun 2017, at 07:33, Nick Coghlan wrote: > > On 14 June 2017 at 13:02, Mahmoud Hashemi wrote: >> That would be amazing! If there's anything I can do to help make that >> happen, please let me know. It'll almost certainly save that much time for >> me alone down the line, anyway :) > > T