Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-20 Thread Rhodri James
On 20/07/18 14:06, Michel Desmoulin wrote: Proposal a __very__ dumbed down "try" expression variable = try Expression as not sentinel [else default] I like this approach. I think it should play nice with the ternary if, though I

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-20 Thread Grégory Lielens
I like it much better than the operator version, if I understand correctly, it's like a watcher for special value, that monitor the stack. Danger is that it monitor the whole stack, so that final result is dependent on how much you decompose your algorithm into nested fiction calls: all return

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-20 Thread Michel Desmoulin
Proposal a __very__ dumbed down "try" expression variable = try Expression as not sentinel [else default] The semantic is: 1 - try the expression. If any call (from a normal method, or a __dunder__ one) returns the sentinel, we

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Judah Levy
One of the big problems with most of the proposed spellings is that question marks to a learner will feel like truthiness tests and not None tests. I would propose adding a new default statement for the most useful part of this PEP, the ?= assignment currently: if x is None: x = blah with

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Chris Angelico
On Fri, Jul 20, 2018 at 10:24 PM, Paul Moore wrote: > On 20 July 2018 at 13:16, Chris Angelico wrote: >> On Fri, Jul 20, 2018 at 10:14 PM, Rhodri James wrote: >>> I go with SF fandom's traditional :-) definition: "somebody did it once." >>> If it's been done more than once, it's an honoured

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Paul Moore
On 20 July 2018 at 13:16, Chris Angelico wrote: > On Fri, Jul 20, 2018 at 10:14 PM, Rhodri James wrote: >> I go with SF fandom's traditional :-) definition: "somebody did it once." >> If it's been done more than once, it's an honoured tradition. > > But if Shakespeare did it, it's just the way

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Chris Angelico
On Fri, Jul 20, 2018 at 10:14 PM, Rhodri James wrote: > I go with SF fandom's traditional :-) definition: "somebody did it once." > If it's been done more than once, it's an honoured tradition. But if Shakespeare did it, it's just the way the language is. I think Fortran is the programming

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Rhodri James
On 20/07/18 01:30, Greg Ewing wrote: Rhodri James wrote: On 19/07/18 07:06, Greg Ewing wrote: There's no such tradition for the new operators being proposed. There is, actually, it's just not a long one.  C# has had null-aware operators for a while, for example. THere's a precedent, yes,

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Grégory Lielens
On Friday, July 20, 2018 at 11:12:26 AM UTC+2, Chris Angelico wrote: > > On Fri, Jul 20, 2018 at 5:10 PM, Grégory Lielens > > wrote: > > Excuse me, that wasn't my words you quoted. Watch your citations please :) > > ChrisA > Yes, sorry, it was Brendan Barnwell. And I can not edit my previous

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Chris Angelico
On Fri, Jul 20, 2018 at 5:10 PM, Grégory Lielens wrote: > > >> On 2018-07-19 02:11, Chris Angelico wrote: > > >> >> -snip- >> As far as I can see, these null-coalescing operators would break >> that >> model. The PEP doesn't seem to provide for a "real" magic method >> allowing users to

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-20 Thread Grégory Lielens
On 2018-07-19 02:11, Chris Angelico wrote: > -snip- > As far as I can see, these null-coalescing operators would break > that > model. The PEP doesn't seem to provide for a "real" magic method > allowing users to override the actual behavior of the method. (You can > only

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-20 Thread Aliaksei Yaletski
Hi I'm new to that list, hope, that my idea will be helpfull. hi = hi OR len(a) > --- > where (A OR B) returns A if A is not None, otherwise it returns B. > Probably, we can introduce syntactic sugar for "if not equal" comparison? Not only for "is not None" check, but for comparison with any

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Steven D'Aprano
On Thu, Jul 19, 2018 at 05:32:48PM +0900, Stephen J. Turnbull wrote: > To be honest, code transformations like this > > > class BaseUploadObject(object): > > def find_content_type(self, filename): > > ctype, encoding = mimetypes.guess_type(filename) > >

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Stephen J. Turnbull
Terry Reedy writes: > On 7/19/2018 4:32 AM, Stephen J. Turnbull wrote: > > make me cringe. Exactly one of two things is true: > > It seems to me that the problem is returning None. Exactly, but this seems to indicate that the problem I'm talking about is the code. It's not; my issue is

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Stephen J. Turnbull
Steve Dower writes: > But for me, the ?? operator makes its strongest case when you are > getting attributes from potentially None values: > > x = maybe_get()?.get_int() ?? 0 > y = maybe_get()?.get_list() ?? [] > > In this case, using 'or' may replace an intentionally falsie

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread David Mertz
On Thu, Jul 19, 2018, 9:39 AM Steven D'Aprano wrote: > *Its just spelling*. If it is a useful and well-defined feature, we'll > get used to the spelling soon enough. > > That's not to say that spelling is not important *at all*, or that we > should never prefer words to symbols. But if the only

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Michael Selik
On Thu, Jul 19, 2018 at 8:40 PM Michael Lee wrote: > >1. ... > >2. We can already easily get the same functionality using standard >Python. E.g., instead of doing foo?["bar"]?[0]?["baz"], we could do > lookup(foo, >"bar", 0, "baz") where lookup is a function that looks roughly

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Greg Ewing
David Mertz wrote: "APL and Perl territory" means "use lots of punctuation characters in somewhat cryptic ways, often combining several for a distinct semantics." And APL takes it a step further by freely making up new characters when it runs out of existing ones. At least nobody has

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Greg Ewing
Calvin Spealman wrote: Operators that only vary by case would be... confusing. Also I'd prefer to see AND and OR (or maybe And and Or) reserved for possible use as overridable, non-short-circuiting forms of "and" and "or" for use by DSLs. -- Greg

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Greg Ewing
Nathan wrote: How many programmer will read "||" or "OR" as a classic "or" operator? It will certainly confuse someone who has any C reflexes, since "||" in C is just a boolean "or". -- Greg ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Todd
On Thu, Jul 19, 2018, 08:47 Rhodri James wrote: > On 19/07/18 09:33, Antoine Pitrou wrote: > > There is a use case I sympathize with: the argument-is-None case. For > > that I would suggest a simpler form: "A else B" which would evaluate > > to A if A is not None, otherwise to B (parentheses

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Greg Ewing
Rhodri James wrote: On 19/07/18 07:06, Greg Ewing wrote: There's no such tradition for the new operators being proposed. There is, actually, it's just not a long one. C# has had null-aware operators for a while, for example. THere's a precedent, yes, but I wouldn't call it a tradition. A

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Chris Angelico
On Fri, Jul 20, 2018 at 10:03 AM, Greg Ewing wrote: > Rhodri James wrote: >> >> If anyone can think of a good word for "if it isn't None, otherwise", I'd >> be all for it :-) > > > I don't think there's any single Engish word that captures > all of that, so we'd have to invent one. > > Some

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Greg Ewing
Rhodri James wrote: If anyone can think of a good word for "if it isn't None, otherwise", I'd be all for it :-) I don't think there's any single Engish word that captures all of that, so we'd have to invent one. Some suggestions: inno (If Not None, Otherwise) oft (Or, Failing That) --

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Greg Ewing
Jonathan Fine wrote: Perhaps "argue" is not the right word here. It sounds too much for or against. And it has implications of being heated and angry. At least arguing about the nature of argument is a very Pythonic thing to do. "That's not arguing, it's just contradiction!" "No, it isn't!"

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Michael Selik
On Thu, Jul 19, 2018 at 5:29 PM Steve Dower wrote: > * "It makes it more complex" > * "It's harder to follow the flow" > > Depends on your measure of complexity. For me, I prioritise "area under > the indentation" as my preferred complexity metric (more lines*indents > == more complex), as well

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Michael Selik
On Thu, Jul 19, 2018 at 2:19 PM Terry Reedy wrote: > It seems to me that the problem is returning None. If functions raised errors instead of returning None, we wouldn't have so much trouble. Much of the benefit of PEP-572 was handling Nones and similar sentinel values. Instead of providing

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Steven D'Aprano
On Thu, Jul 19, 2018 at 11:39:50AM -0700, Brendan Barnwell wrote: > On 2018-07-19 06:38, Steven D'Aprano wrote: > >*Its just spelling*. If it is a useful and well-defined feature, we'll > >get used to the spelling soon enough. > > > >That's not to say that spelling is not important *at all*, or

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Steve Dower
Thanks everyone for the feedback and discussion so far. I want to address some of the themes, so apologies for not quoting individuals and for doing this in one post instead of twenty. -- * "It looks like line noise" Thanks for the feedback. There's nothing constructive for me to take

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread MRAB
On 2018-07-19 20:23, Terry Reedy wrote: On 7/19/2018 8:30 AM, Jonathan Fine wrote: Hi There is a formatted version of this PEP at https://www.python.org/dev/peps/pep-0505/ I've taken a look at this, and have some comments on the first two examples drawn from standard library code. (And a

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Terry Reedy
On 7/19/2018 8:30 AM, Jonathan Fine wrote: Hi There is a formatted version of this PEP at https://www.python.org/dev/peps/pep-0505/ I've taken a look at this, and have some comments on the first two examples drawn from standard library code. (And a very grateful +10 for writing a script to

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Chris Angelico
On Fri, Jul 20, 2018 at 4:45 AM, Stephan Houben wrote: > Let me just address this point: > > 2018-07-19 20:36 GMT+02:00 Brendan Barnwell : >> >> As far as I can see, these null-coalescing operators would break >> that model. The PEP doesn't seem to provide for a "real" magic method >>

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Stephan Houben
Let me just address this point: 2018-07-19 20:36 GMT+02:00 Brendan Barnwell : > As far as I can see, these null-coalescing operators would break > that model. The PEP doesn't seem to provide for a "real" magic method > allowing users to override the actual behavior of the method. (You

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Elazar
On Thu, Jul 19, 2018 at 11:37 AM Brendan Barnwell wrote: > > As far as I can see, these null-coalescing operators would break > that > model. The PEP doesn't seem to provide for a "real" magic method > allowing users to override the actual behavior of the method. (You can > only

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Terry Reedy
On 7/19/2018 4:33 AM, Antoine Pitrou wrote: This is adding a whole range of new operators without enough of a use case. It is also making code harder to read, as evaluation can stop at any of the "?*" operators. And it looks like noise (or like Perl 6, which is the same). There is a use case

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Brendan Barnwell
On 2018-07-19 06:38, Steven D'Aprano wrote: *Its just spelling*. If it is a useful and well-defined feature, we'll get used to the spelling soon enough. That's not to say that spelling is not important *at all*, or that we should never prefer words to symbols. But if the only objection we have

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Brendan Barnwell
On 2018-07-19 02:11, Chris Angelico wrote: Okay. What about bitwise operators, then? They don't have centuries of mathematical backing to support them, yet it isn't considered "unpythonic" to have &|^~ peppering our code. Judging by the current levels of backlash against symbolic operators, it

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Terry Reedy
On 7/19/2018 4:32 AM, Stephen J. Turnbull wrote: Chris Angelico writes later in thread: > On Thu, Jul 19, 2018 at 9:55 AM, Giampaolo Rodola' wrote: > Personally, I'm +0 on this. It'd be a few small wins here and there, > nothing huge, and I could easily live without it; but it's

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread MRAB
On 2018-07-19 14:26, Stephan Houben wrote: FWIW, I like ?? It is short and distinctive. There is prior art in this spelling in c#. It requires no new keyword, nor does it give new meaning to an existing one. I understand why  ?[ needs to be spelled using only a single ?, but I am afraid it

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Calvin Spealman
The concatenated name reads a little weird. Alternatively, extend the conditional expression syntax. a = b if None c equivalent to a = b if b is None else c On Thu, Jul 19, 2018 at 9:35 AM, Robert Vanden Eynde wrote: > If we're about to use a new keyword, it could be infix too: > > a = b

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread David Mertz
"APL and Perl territory" means "use lots of punctuation characters in somewhat cryptic ways, often combining several for a distinct semantics." I did not mean "APL and Perl use those specific characters with the proposed meaning." On Thu, Jul 19, 2018, 9:39 AM Steven D'Aprano wrote: > On Wed,

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Steven D'Aprano
On Wed, Jul 18, 2018 at 08:05:56PM -0400, David Mertz wrote: > '??' and '?.' and ?[]' are really just marching > into APL and Perl territory. Yes, I know such operators exist in other > languages, but it feels very unpythonic. If these features exist in "other languages", and *don't* exist in

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Robert Vanden Eynde
If we're about to use a new keyword, it could be infix too: a = b ifnone c Although the assignment version looks unusual: b ifnone= c Then with the "default b = c" would look like this: ifnone b = c Le jeu. 19 juil. 2018 à 15:30, Calvin Spealman a écrit : > Operators that only vary by case

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Calvin Spealman
Operators that only vary by case would be... confusing. I'm not super keen on the other syntax (either the ?? or .? operators) but I do think they read well in C# where they come from. Different things work in different languages, some times. What about a new keyword: default So you'd write the

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Nathan
working in your code. So -1 on that idea even if PEP 505 were accepted. Nathan Mugnier         > Message du 19/07/18 15:06 > De : "Pål Grønås Drange" > A : "Jonathan Fine" > Copie à : "Python-Ideas" > Objet : Re: [Python-ideas] PEP 505: None-awar

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Stephan Houben
FWIW, I like ?? It is short and distinctive. There is prior art in this spelling in c#. It requires no new keyword, nor does it give new meaning to an existing one. I understand why ?[ needs to be spelled using only a single ?, but I am afraid it will be used infrequently, and people will

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Paul Moore
On 19 July 2018 at 13:39, Rhodri James wrote: >> After updating to use the ``?[]`` and ``??`` operators:: >> >> def _get_const_info(const_index, const_list): >> argval = const_list?[const_index] ?? const_index >> return argval, repr(argval) > > > Here's where I start to

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Pål Grønås Drange
> I've started a subthread, just to discuss the ?= and ?? operators. And > something newish, that I call OR. I would think `||` would be much better. It could be a kind of "semantic or" which could use the aforementioned dunder has_value. -1, though, but to the general None-awareness. Pål

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Paul Moore
On 19 July 2018 at 13:30, Jonathan Fine wrote: > Hi > >> There is a formatted version of this PEP at >> https://www.python.org/dev/peps/pep-0505/ > > I've taken a look at this, and have some comments on the first two > examples drawn from standard library code. (And a very grateful +10 > for

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Judah Levy
On Thu, Jul 19, 2018 at 8:47 AM Rhodri James wrote: > On 19/07/18 09:33, Antoine Pitrou wrote: > > There is a use case I sympathize with: the argument-is-None case. For > > that I would suggest a simpler form: "A else B" which would evaluate > > to A if A is not None, otherwise to B

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Rhodri James
On 19/07/18 07:06, Greg Ewing wrote: Chris Angelico wrote: I'd love to hear an explanation of WHY this doesn't look like Python any more. For instance, is the + operator somehow wrong for Python, and it should have been the word "add"? There's a very long tradition of using the symbol "+" to

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Rhodri James
On 19/07/18 09:33, Antoine Pitrou wrote: There is a use case I sympathize with: the argument-is-None case. For that I would suggest a simpler form: "A else B" which would evaluate to A if A is not None, otherwise to B (parentheses may be mandatory). So e.g. one of the examples would read:

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Rhodri James
On 18/07/18 18:43, Steve Dower wrote: Possibly this is exactly the wrong time to propose the next big syntax change, since we currently have nobody to declare on it, but since we're likely to argue for a while anyway it probably can't hurt (and maybe this will become the test PEP for whoever

Re: [Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR

2018-07-19 Thread Jonathan Fine
Hi > There is a formatted version of this PEP at > https://www.python.org/dev/peps/pep-0505/ I've taken a look at this, and have some comments on the first two examples drawn from standard library code. (And a very grateful +10 for writing a script to find such examples.) I've started a

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread David Mertz
On Thu, Jul 19, 2018, 5:12 AM Chris Angelico wrote: > On Thu, Jul 19, 2018 at 4:06 PM, Greg Ewing > wrote: > > There's a very long tradition of using the symbol "+" to > > represent addition, so it's something most people are > > familiar with. There's no such tradition for the new > >

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Giampaolo Rodola'
On Thu, Jul 19, 2018 at 11:22 AM Antoine Pitrou wrote: > > On Thu, 19 Jul 2018 19:11:33 +1000 > Chris Angelico wrote: > > > On Thu, Jul 19, 2018 at 4:06 PM, Greg Ewing > > wrote: > > > Chris Angelico wrote: > > >> > > >> I'd love to hear an explanation of WHY this doesn't look like Python > >

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Antoine Pitrou
On Thu, 19 Jul 2018 19:11:33 +1000 Chris Angelico wrote: > On Thu, Jul 19, 2018 at 4:06 PM, Greg Ewing > wrote: > > Chris Angelico wrote: > >> > >> I'd love to hear an explanation of WHY this doesn't look like Python > >> any more. For instance, is the + operator somehow wrong for Python, >

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Chris Angelico
On Thu, Jul 19, 2018 at 4:06 PM, Greg Ewing wrote: > Chris Angelico wrote: >> >> I'd love to hear an explanation of WHY this doesn't look like Python >> any more. For instance, is the + operator somehow wrong for Python, >> and it should have been the word "add"? > > > There's a very long

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Greg Ewing
Chris Angelico wrote: I'd love to hear an explanation of WHY this doesn't look like Python any more. For instance, is the + operator somehow wrong for Python, and it should have been the word "add"? There's a very long tradition of using the symbol "+" to represent addition, so it's something

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Chris Angelico
On Thu, Jul 19, 2018 at 5:45 PM, Brice Parent wrote: > The biggest drawback of this, is that (if I understand it well), it may be > done quite easily without any change to the language: > > def first_set(*elements): # please don't mind the name of the function, > it's not the purpose here >

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Antoine Pitrou
This is adding a whole range of new operators without enough of a use case. It is also making code harder to read, as evaluation can stop at any of the "?*" operators. And it looks like noise (or like Perl 6, which is the same). There is a use case I sympathize with: the argument-is-None

[Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Stephen J. Turnbull
Chris Angelico writes later in thread: > On Thu, Jul 19, 2018 at 9:55 AM, Giampaolo Rodola' > wrote: > Personally, I'm +0 on this. It'd be a few small wins here and there, > nothing huge, and I could easily live without it; but it's something > that I know some people will love. I am 100%

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread INADA Naoki
Honestly speaking, I don't want make Python syntax more complex. But when comparing to accepted PEP 572, I think this PEP is useful often enough. And PEP 505 doesn't break border between expression and statement unlike PEP 572. Especially, ?? and ??= seems useful very often. And `x ?? default`

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread Brice Parent
Hi, I think this breaks one of the most important aspect which makes Python more and more popular every year: its readability. Until now, you didn't need to know the language very well to have some understanding about what a script did. Some parts of it could be a bit complicated (like

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-19 Thread George Leslie-Waksman
I am rather fond of the idea of null-coalescing, at the very least, for mutable default values: def foo(a=None): a ??= [] ... but I worry about the code messes we will run into with some of the other options. Woe be unto anyone forced to understand the behavior of:

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread Tim Peters
[Steve Dower ] > ... * The "``None``-aware attribute access" operator ``?.`` evaluates the > complete expression if the left hand side evaluates to a value that is not > ``None`` > And if the LHS does evaluate to `None` ...? I'll assume the result is also `None` then. > ... > From

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread Giampaolo Rodola'
On Thu, Jul 19, 2018 at 2:06 AM Chris Angelico wrote: > > With all due respect (and I am sorry for being “vocal” about a PEP once > > again) I find this simply ugly. To me this basically doesn’t look like > > python anymore, so a strong -1 from me. > > I'd love to hear an explanation of WHY this

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread David Mertz
The examples in the PEP strengthen my opinion. I think every one of them read much more clearly in the existing syntax. I can only understand any by mentally inserting 'if Foo is None' everywhere... Basically mentally replacing the "code golf" syntax with the actual intent that is spelled like it

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread David Mertz
As before, I'm a strong -1 on this. I recognize the semantic utility (albeit, I've needed it much less than some folks testify). But the obscure characters are accumulating far too fast with this. Even with PEP 572, I would have preferred 'as' and restrictions on where it's allowed, but ':=' is

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread Chris Angelico
On Thu, Jul 19, 2018 at 9:55 AM, Giampaolo Rodola' wrote: [ please trim quotes, you just quoted the entire PEP in your post ] > With all due respect (and I am sorry for being “vocal” about a PEP once > again) I find this simply ugly. To me this basically doesn’t look like > python anymore, so a

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread Giampaolo Rodola'
On Wed, Jul 18, 2018 at 7:46 PM Steve Dower wrote: > > Possibly this is exactly the wrong time to propose the next big syntax > change, since we currently have nobody to declare on it, but since we're > likely to argue for a while anyway it probably can't hurt (and maybe > this will become the

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread Steve Dower
Thanks! Bit of discussion below about precedence, but thanks for spotting the typos. On 18Jul2018 1318, MRAB wrote: On 2018-07-18 18:43, Steve Dower wrote: Grammar changes --- The following rules of the Python grammar are updated to read::   augassign: ('+=' | '-=' | '*=' |

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread MRAB
On 2018-07-18 18:43, Steve Dower wrote: Possibly this is exactly the wrong time to propose the next big syntax change, since we currently have nobody to declare on it, but since we're likely to argue for a while anyway it probably can't hurt (and maybe this will become the test PEP for whoever

[Python-ideas] PEP 505: None-aware operators

2018-07-18 Thread Steve Dower
Possibly this is exactly the wrong time to propose the next big syntax change, since we currently have nobody to declare on it, but since we're likely to argue for a while anyway it probably can't hurt (and maybe this will become the test PEP for whoever takes the reins?). FWIW, Guido had

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Guido van Rossum
On Fri, Oct 14, 2016 at 6:37 AM, Gustavo Carneiro wrote: > I see. short-circuiting is nice to have, sure. No. Short-circuiting is the entire point of the proposed operators. -- --Guido van Rossum (python.org/~guido) ___

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Mark E. Haase
On Fri, Oct 14, 2016 at 9:37 AM, Gustavo Carneiro wrote: > > I see. short-circuiting is nice to have, sure. > > But even without it, it's still useful IMHO. > It's worth mentioning that SQL's COALESCE is usually (always?) short circuiting:

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Franklin? Lee
My mistake. You're talking about the ?? operator, and I'm thinking about the null-aware operators. You say short-circuiting would be nice to have, but short-circuiting is what people want it for. As for using `if-else`, that's listed as an alternative here:

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Franklin? Lee
On Oct 14, 2016 9:14 AM, "Gustavo Carneiro" wrote: > > Sorry if I missed the boat, but only just now saw this PEP. > > Glancing through the PEP, I don't see mentioned anywhere the SQL alternative of having a coalesce() function:

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Gustavo Carneiro
On 14 October 2016 at 14:19, אלעזר wrote: > On Fri, Oct 14, 2016 at 4:14 PM Gustavo Carneiro > wrote: > >> Sorry if I missed the boat, but only just now saw this PEP. >> >> Glancing through the PEP, I don't see mentioned anywhere the SQL >> alternative

Re: [Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread אלעזר
On Fri, Oct 14, 2016 at 4:14 PM Gustavo Carneiro wrote: > Sorry if I missed the boat, but only just now saw this PEP. > > Glancing through the PEP, I don't see mentioned anywhere the SQL > alternative of having a coalesce() function: >

[Python-ideas] PEP 505 -- None-aware operators

2016-10-14 Thread Gustavo Carneiro
Sorry if I missed the boat, but only just now saw this PEP. Glancing through the PEP, I don't see mentioned anywhere the SQL alternative of having a coalesce() function: https://www.postgresql.org/docs/9.6/static/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL In Python, something like

<    1   2   3