[Python-ideas] Re: Implementing string unary operators

2021-10-20 Thread Steven D'Aprano
On Wed, Oct 20, 2021 at 11:30:50AM +0900, Stephen J. Turnbull wrote: > Steven D'Aprano writes: > > > Ironically, Ricky's in-fun suggestion that we use the tilde operator for > > swapcase was the only suggestion in these two threads that actually met > > the invariant for an inverse that ~~x =

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread Stephen J. Turnbull
Steven D'Aprano writes: > Ironically, Ricky's in-fun suggestion that we use the tilde operator for > swapcase was the only suggestion in these two threads that actually met > the invariant for an inverse that ~~x == x. You forgot about Turkish, I think it is, that has three cases (the third

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread Chris Angelico
On Wed, Oct 20, 2021 at 12:02 PM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2021-10-20 at 11:48:30 +1100, > Chris Angelico wrote: > > > TBH swapcase is a bit of a minefield if you don't know what language > > you're working with. > > [...] > > > The most logical "negation" of a string woul

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread 2QdxY4RzWzUUiLuE
On 2021-10-20 at 11:48:30 +1100, Chris Angelico wrote: > TBH swapcase is a bit of a minefield if you don't know what language > you're working with. [...] > The most logical "negation" of a string would be reversing it, which > WOULD be... well, reversible. But that doesn't need an operator, si

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread Chris Angelico
On Wed, Oct 20, 2021 at 11:35 AM Steven D'Aprano wrote: > > On Wed, Oct 20, 2021 at 11:10:52AM +1100, Chris Angelico wrote: > > On Wed, Oct 20, 2021 at 11:02 AM Steven D'Aprano > > wrote: > > > Ironically, Ricky's in-fun suggestion that we use the tilde operator for > > > swapcase was the only s

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread Ricky Teachey
I'm here all week. Tip your wait staff. Also, genuine apologies if mine was perceived as mean-sarcastic. It was definitely sarcastic but I hoped it was fun enough in tone not to seem mean-spirited. I apologize sincerely and without reservation and I would do it better next time. :) On Tue, Oct 19

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread Steven D'Aprano
On Tue, Oct 12, 2021 at 05:30:13PM -0700, Guido van Rossum wrote: > I would also like to remind various other posters that sarcasm is *not* a > good way to welcome newbies. The name of the list is python-ideas, not > python-ideas-to-shoot-down-sarcastically. Guido, it isn't fair of you to jump in

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread Steven D'Aprano
On Wed, Oct 20, 2021 at 11:10:52AM +1100, Chris Angelico wrote: > On Wed, Oct 20, 2021 at 11:02 AM Steven D'Aprano wrote: > > Ironically, Ricky's in-fun suggestion that we use the tilde operator for > > swapcase was the only suggestion in these two threads that actually met > > the invariant for a

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread Chris Angelico
On Wed, Oct 20, 2021 at 11:02 AM Steven D'Aprano wrote: > Ironically, Ricky's in-fun suggestion that we use the tilde operator for > swapcase was the only suggestion in these two threads that actually met > the invariant for an inverse that ~~x == x. > >>> x = "ß" :) Okay, so it's *mostly* an in

[Python-ideas] Re: Implementing string unary operators

2021-10-19 Thread Steven D'Aprano
On Tue, Oct 12, 2021 at 05:10:45PM -0700, Jelle Zijlstra wrote: > Your other post mostly attracted sarcastic replies, so I'll be more direct: > It's highly unlikely that this will go anywhere. Jelle, the second part of your sentence may be true, but the first part is not. It is unfair and inaccu

[Python-ideas] Re: Implementing string unary operators

2021-10-14 Thread Jeremiah Vivian
(gonna test highlighting) \> ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.or

[Python-ideas] Re: Implementing string unary operators

2021-10-14 Thread Jeremiah Vivian
Now I didn't expect this thread to blow up in replies with alternatives, specifically `str1 / str2` for 'str1.split(str2)' and `seq1 * str` for 'str.join(seq1)'. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to py

[Python-ideas] Re: Implementing string unary operators

2021-10-13 Thread Serhiy Storchaka
13.10.21 03:10, Jelle Zijlstra пише: > To get a new operator on a builtin type, you'll have to show that: > - It's a common operation; > - There's no convenient way to do it already; and > - The meaning of the operator is reasonably clear to a reader of the code. > > Recent examples of new feature

[Python-ideas] Re: Implementing string unary operators

2021-10-13 Thread Serhiy Storchaka
13.10.21 03:05, MarylandBall Productions пише: > I would think `~string` could be good for a shorthand way to convert a string > to an integer, considering you’re “inverting” the string to another type, > though a downside to this would be that explicit is always better than > implicit and ~stri

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Stephen J. Turnbull
It was written: > How is `int(string, 16)` "inverting"? It's the inverse of f"{number:x}", of course. Mappings between types are ubiquitous, and (more or less) invertible ones are not uncommon. It's an honest question, but I suggest we let slightly odd usage, especially in scare quotes, pass.

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Steven D'Aprano
On Wed, Oct 13, 2021 at 12:05:35AM -, MarylandBall Productions wrote: > I would think `~string` could be good for a shorthand way to convert a > string to an integer, considering you’re “inverting” the string to > another type How is `int(string, 16)` "inverting"? Inverting means to flip o

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Steven D'Aprano
On Tue, Oct 12, 2021 at 11:50:27PM -, Jeremiah Vivian wrote: > I posted a previous thread about overloading the unary `+` operator in > strings with `ord`, and that expanded to more than just the unary `+` > operator. So I'm saying now, there should be these implementations: Did you actuall

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Guido van Rossum
On Tue, Oct 12, 2021 at 5:21 PM Jeremiah Vivian < nohackingofkrow...@gmail.com> wrote: > So I guess I'll just have to keep this to myself. > I know this is disappointing, but in this case I agree with Jelle -- this particular idea does not fit well in Python's design, it looks like an attempt at

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Jeremiah Vivian
> "inverting" the string to another type ...That doesn't make any sense. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Chris Angelico
On Wed, Oct 13, 2021 at 11:21 AM MarylandBall Productions wrote: > > I would think `~string` could be good for a shorthand way to convert a string > to an integer, considering you’re “inverting” the string to another type, > though a downside to this would be that explicit is always better than

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Jeremiah Vivian
So I guess I'll just have to keep this to myself. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at h

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread MarylandBall Productions
I would think `~string` could be good for a shorthand way to convert a string to an integer, considering you’re “inverting” the string to another type, though a downside to this would be that explicit is always better than implicit and ~string will be a confusing operation to many users. ___

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Jelle Zijlstra
El mar, 12 oct 2021 a las 16:51, Jeremiah Vivian (< nohackingofkrow...@gmail.com>) escribió: > I posted a previous thread about overloading the unary `+` operator in > strings with `ord`, and that expanded to more than just the unary `+` > operator. So I'm saying now, there should be these impleme

[Python-ideas] Re: Implementing string unary operators

2021-10-12 Thread Chris Angelico
On Wed, Oct 13, 2021 at 10:53 AM Jeremiah Vivian wrote: > > I posted a previous thread about overloading the unary `+` operator in > strings with `ord`, and that expanded to more than just the unary `+` > operator. So I'm saying now, there should be these implementations: > > +string - `int(stri