Re: [Python-ideas] Add "default" kw argument to operator.itemgetter and operator.attrgetter

2018-05-02 Thread Raymond Hettinger
> On May 2, 2018, at 1:08 AM, Vincent Maillol wrote: > > Our PEP idea would be to purpose to add a global default value for > itemgeet and attrgetter method. My preference is to not grow that API further. It is creep well beyond its intended uses. At some point,

Re: [Python-ideas] Add "default" kw argument to operator.itemgetter and operator.attrgetter

2018-05-02 Thread Steven D'Aprano
On Wed, May 02, 2018 at 10:08:55AM +0200, Vincent Maillol wrote: > Hi everybody, > > Our PEP idea would be to purpose to add a global default value for > itemgeet and attrgetter method. I'm sorry, I'm not sure I understand what you mean by a global default. My interpretation of that would be

Re: [Python-ideas] Please consider adding partialclass to functools

2018-05-02 Thread Steven D'Aprano
On Wed, May 02, 2018 at 02:46:09PM -0700, Neil Girdhar wrote: > Essentially, functools.partial is almost good enough for specifying some of > the parameters of an object's initializer, but the partial object doesn't > respond properly to issubclass. [...] I think that ought to be an

[Python-ideas] Please consider adding partialclass to functools

2018-05-02 Thread Neil Girdhar
Essentially, functools.partial is almost good enough for specifying some of the parameters of an object's initializer, but the partial object doesn't respond properly to issubclass. Please consider adding something like partialclass described here:

Re: [Python-ideas] A "local" pseudo-function

2018-05-02 Thread Tim Peters
[MRAB] >> There's another question that hasn't been asked yet: what should locals() >> and globals() return? [Tim, "globals()" is obvious, "locals()" can be surprising now] > ... And here recording the results of some code spelunking Dicts don't really have anything to do with how locals are

Re: [Python-ideas] Yet another idea for assignment expressions

2018-05-02 Thread Rhodri James
On 02/05/18 07:21, Ken Hilton wrote: Going back to the regex example, this is how it would look in that case: if re.match(exp, string){m}: print(m.group(0)) The various other options at least suggest that in some manner what is going on is an assignment. This really doesn't.

Re: [Python-ideas] Objectively Quantifying Readability

2018-05-02 Thread Greg Ewing
Tim Peters wrote: def objective_readability_score(text): "Return the readability of `text`, a float in 0.0 .. 1.0" return 2.0 * text.count(":=") / len(text) A useful-looking piece of code, but it could be more readable. It only gives itself a readability score of 0.0136986301369863.

Re: [Python-ideas] A "local" pseudo-function

2018-05-02 Thread Greg Ewing
Steven D'Aprano wrote: y = 1 def func(): x = 2 return x+y Here, there's a local environment as well as an implicit global one. Surely we don't want to call this a closure? Python probably isn't the best choice of language for the point you're making, because even top-level functions

Re: [Python-ideas] Yet another idea for assignment expressions

2018-05-02 Thread Jacco van Dorp
I kind of strangely like this, but it does something completely different from parens or []. Those do have something in common - func(param) and indexable[index] both result in some value obtained in some way by combining the two names - either it's the result of func when called with param, or

Re: [Python-ideas] A way to subscript a single integer from bytes

2018-05-02 Thread Jacco van Dorp
> I think this method is easy to miss, since people look at the docs for bytes > (e.g. using dir(bytes)). It might be worthwhile to either add a > `bytes.to_int(...)` method (better, IMHO), or to point to int.from_bytes on > the relevant part of the docs. > > Elazar A note in the docs about

[Python-ideas] Yet another idea for assignment expressions

2018-05-02 Thread Ken Hilton
Hi all, I've been following the discussion of assignment expressions and what the syntax for them should be for awhile. The ones that seem to crop up most are the original spelling, :=, the "as" keyword (and variants including it), and the recently "local" pseudo-function idea. I have another