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 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 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] Adding Python interpreter info to "pip install"

2018-07-19 Thread Abdur-Rahmaan Janhangeer
as it requires only a log, i think it is worth it as pip acts covertly meaning you don't see which pip is being used in a multi-py environment, yes you can have version pip info Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius > >

Re: [Python-ideas] Adding Python interpreter info to "pip install"

2018-07-19 Thread Nathaniel Smith
On Thu, Jul 19, 2018 at 5:45 PM, Al Sweigart wrote: > The goal of this idea is to make it easier to find out when someone has > installed packages for the wrong python installation. I'm coming across > quite a few StackOverflow posts and emails where beginners are using pip to > install a

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

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 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] Adding Python interpreter info to "pip install"

2018-07-19 Thread Chris Angelico
On Fri, Jul 20, 2018 at 10:45 AM, Al Sweigart wrote: > The goal of this idea is to make it easier to find out when someone has > installed packages for the wrong python installation. I'm coming across > quite a few StackOverflow posts and emails where beginners are using pip to > install a

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 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: 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: 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] Adding Python interpreter info to "pip install"

2018-07-19 Thread Al Sweigart
Sorry, I meant "pip list", rather than "pip info". I thought about the fact that "pip --version" provides this info, but 1) it provides the location of pip, not the python interpreter it installs packages for and 2) it would be an additional step for the question-asker to go through after

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

[Python-ideas] Adding Python interpreter info to "pip install"

2018-07-19 Thread Al Sweigart
The goal of this idea is to make it easier to find out when someone has installed packages for the wrong python installation. I'm coming across quite a few StackOverflow posts and emails where beginners are using pip to install a package, but then finding they can't import it because they have

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] Adding Python interpreter info to "pip install"

2018-07-19 Thread Wes Turner
`python -m site` and its docs may also be useful for troubleshooting end-user installations. A diagnostic script with e.g. these commands could also be helpful: which python which pip python -m site # sys.path, USER_SITE (pip --user) python -m pip --version >>> print((os.name, sys.platform,

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 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 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 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] Adding Python interpreter info to "pip install"

2018-07-19 Thread Pradyun Gedam
On Fri, 20 Jul 2018, 09:52 Nathaniel Smith, wrote: > On Thu, Jul 19, 2018 at 5:45 PM, Al Sweigart wrote: > > The goal of this idea is to make it easier to find out when someone has > > installed packages for the wrong python installation. I'm coming across > > quite a few StackOverflow posts

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 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 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] Multi-core reference count garbage collection

2018-07-19 Thread Jonathan Fine
Hi Stephan Thank you for the extract from the GC Handbook, which I think I may have seen before. Yes, it is GOOD that it's an already known idea. Searching for "buffered reference counting" I found https://mail.python.org/pipermail/python-dev/2016-October/146696.html in which Larry Hastings says

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 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

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: 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 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] Multi-core reference count garbage collection

2018-07-19 Thread Stephan Houben
Hi Jonathan, 2018-07-19 8:33 GMT+02:00 Jonathan Fine : > I call any such scheme BUFFERED multi-core reference count garbage > collection. The worker processes know nothing about how garbage collection > is managed. Instead, they pass over to the GC process sufficient > information to allow it to

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 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: 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] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-19 Thread Pau Freixes
Hi, > > Note that this everything you said here also exactly describes the > programming model for the existing 'multiprocessing' module: > "structured clone" is equivalent to how multiprocessing uses pickle to > transfer arbitrary objects, or you can use multiprocessing.Array to > get a shared

[Python-ideas] Multi-core reference count garbage collection

2018-07-19 Thread Jonathan Fine
Hi Based on other people's work (including in particular talks by Larry Hastings) and my own thinking, I've come up with a scheme for multi-core reference count garbage collection. I think it works, and much or all of it comes from others. It might even be in the literature. Of course, if it's

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 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 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 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] The future of Python parallelism. The GIL. Subinterpreters. Actors.

2018-07-19 Thread Stephan Houben
Hi Nathaniel, 2018-07-19 1:33 GMT+02:00 Nathaniel Smith : > Note that this everything you said here also exactly describes the > programming model for the existing 'multiprocessing' module: > "structured clone" is equivalent to how multiprocessing uses pickle to > transfer arbitrary objects, or

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 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 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: 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

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

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] Revisiting str.rreplace()

2018-07-19 Thread Eric V. Smith
On 7/19/2018 11:22 AM, Calvin Spealman wrote: If its treated as a missing parameter, and currently doesn't do anything, then it wouldn't be used... right? and it could be safe to add behavior for it... right? It currently does something: it replaces all instances, just as if you hadn't

Re: [Python-ideas] Performance improvements via static typing

2018-07-19 Thread Michael Hall
On Thu, Jul 19, 2018 at 10:02 AM, Eric Fahlgren wrote: > On Thu, Jul 19, 2018 at 6:52 AM Michael Hall > wrote: > >> While I am aware of projects like Cython and mypy, it seems to make sense >> for CPython to allow optional enforcement of type hints, with compiler >> optimizations related to it

Re: [Python-ideas] Performance improvements via static typing

2018-07-19 Thread Michael Hall
On Thu, Jul 19, 2018 at 10:07 AM, Stephan Houben wrote: > You are aware of numba? > > https://numba.pydata.org/ > > Stephan > > Op do 19 jul. 2018 16:03 schreef Eric Fahlgren : > >> On Thu, Jul 19, 2018 at 6:52 AM Michael Hall >> wrote: >> >>> While I am aware of projects like Cython and mypy,

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] Revisiting str.rreplace()

2018-07-19 Thread Eric Fahlgren
On Wed, Jul 18, 2018 at 8:20 PM Graham Gott wrote: > > Thoughts? Support/oppose? > ​ +1, along with an overall rework of str methods to make them more consistent. The find, replace and split families should all gain the same tuple-as-search-string that endswith and startswith use. (Discussed

Re: [Python-ideas] Performance improvements via static typing

2018-07-19 Thread Eric Fahlgren
On Thu, Jul 19, 2018 at 6:52 AM Michael Hall wrote: > While I am aware of projects like Cython and mypy, it seems to make sense > for CPython to allow optional enforcement of type hints, with compiler > optimizations related to it to be used. While this would not receive the > same level of

Re: [Python-ideas] Revisiting str.rreplace()

2018-07-19 Thread Calvin Spealman
If its treated as a missing parameter, and currently doesn't do anything, then it wouldn't be used... right? and it could be safe to add behavior for it... right? On Thu, Jul 19, 2018 at 11:17 AM, Eric V. Smith wrote: > On 7/19/2018 10:01 AM, Calvin Spealman wrote: > >> As an alternative

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] Multi-core reference count garbage collection

2018-07-19 Thread MRAB
On 2018-07-19 11:53, Jonathan Fine wrote: Hi Stephan Thank you for the extract from the GC Handbook, which I think I may have seen before. Yes, it is GOOD that it's an already known idea. Searching for "buffered reference counting" I found

[Python-ideas] Performance improvements via static typing

2018-07-19 Thread Michael Hall
While I am aware of projects like Cython and mypy, it seems to make sense for CPython to allow optional enforcement of type hints, with compiler optimizations related to it to be used. While this would not receive the same level of performance benefits as using ctypes directly, there do appear to

Re: [Python-ideas] Revisiting str.rreplace()

2018-07-19 Thread Calvin Spealman
It would be consistent to apply it to other functions and I'd be in favour of that, yes. On Thu, Jul 19, 2018 at 10:06 AM, Eric Fahlgren wrote: > On Thu, Jul 19, 2018 at 7:01 AM Calvin Spealman > wrote: > >> As an alternative suggestion: What if the count parameter to >> str.replace() counted

Re: [Python-ideas] Revisiting str.rreplace()

2018-07-19 Thread Calvin Spealman
As an alternative suggestion: What if the count parameter to str.replace() counted from the right with negative values? That would be consistent with other things like indexing and slicing. On Thu, Jul 19, 2018 at 9:47 AM, Eric Fahlgren wrote: > On Wed, Jul 18, 2018 at 8:20 PM Graham Gott com>

Re: [Python-ideas] Revisiting str.rreplace()

2018-07-19 Thread Eric V. Smith
On 7/19/2018 10:01 AM, Calvin Spealman wrote: As an alternative suggestion: What if the count parameter to str.replace() counted from the right with negative values? That would be consistent with other things like indexing and slicing. We couldn't make this change because negative values

Re: [Python-ideas] Revisiting str.rreplace()

2018-07-19 Thread MRAB
On 2018-07-19 16:22, Calvin Spealman wrote: If its treated as a missing parameter, and currently doesn't do anything, then it wouldn't be used... right? and it could be safe to add behavior for it... right? Are you sure that it wouldn't break some existing code? Plus, we already have

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

2018-07-19 Thread Nathan
Hello. Even if I'm -1 on the general idea of a None-aware, for a lot of reason already mentionned in this thread, the syntax "??" proposed (that I find much less readable than the current version) is still better IMHO. How many programmer will read "||" or "OR" as a classic "or" operator?

Re: [Python-ideas] Revisiting str.rreplace()

2018-07-19 Thread Eric Fahlgren
On Thu, Jul 19, 2018 at 7:01 AM Calvin Spealman wrote: > As an alternative suggestion: What if the count parameter to str.replace() > counted from the right with negative values? That would be consistent with > other things like indexing and slicing. > ​That could certainly be made to work, but

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] Performance improvements via static typing

2018-07-19 Thread Stephan Houben
You are aware of numba? https://numba.pydata.org/ Stephan Op do 19 jul. 2018 16:03 schreef Eric Fahlgren : > On Thu, Jul 19, 2018 at 6:52 AM Michael Hall > wrote: > >> While I am aware of projects like Cython and mypy, it seems to make sense >> for CPython to allow optional enforcement of

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 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 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 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 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 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 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: 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: 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] Revisiting str.rreplace()

2018-07-19 Thread Paul Moore
On 19 July 2018 at 16:25, Eric V. Smith wrote: > It currently does something: it replaces all instances, just as if you > hadn't supplied a count (see my example below). You can't change its > behavior. ... without a deprecation cycle. Which is of course not worth it for something which could

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