[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: Unpacking in tuple/list/set/dict comprehensions

2021-10-19 Thread Steven D'Aprano
On Sun, Oct 17, 2021 at 05:02:23PM -0700, Guido van Rossum wrote: > On Sun, Oct 17, 2021 at 4:38 PM Steven D'Aprano wrote: > > > Right-o, the old "heterogeneous tuples versus homogeneous lists" > > distinction, I remember that from the old 1.5 days. I haven't heard it > > mentioned for a long tim

[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: Type-hinting dictionaries for an arbitrary number of arbitrary key/value pairs? Counterpart to PEP 589?

2021-10-19 Thread Sebastian M. Ernst
Hi all, thanks for all the feedback. > But this is probably off-topic. I'm not 100% sure what the OP's > proposal was, but as far as I can tell it seems to me that "dict[str, > Number] is the correct usage for static typing" is the answer, > regardless of mypy's ability to process it. Let me exp

[Python-ideas] Re: Fwd: Simple curl/wget-like download functionality in urllib (like http offers server)

2021-10-19 Thread Tom Pohl
Thanks, finally a +1! \o/ It's funny that "entry point" triggered your reaction, because I think it's not the correct technical term. What I'm proposing is very similar to http.server: https://github.com/python/cpython/blob/3.10/Lib/http/server.py#L1257 Just like "python -m http.server" you co

[Python-ideas] Re: Fwd: Simple curl/wget-like download functionality in urllib (like http offers server)

2021-10-19 Thread Christopher Barker
On Tue, Oct 19, 2021 at 7:32 AM Tom Pohl wrote: > You are absolutely right, the functionality is there, but the idea is to > make it easily available from the command line. > > With the proposed functionality, the urllib could provide a download entry > point which would make the line look like

[Python-ideas] Re: Fwd: Simple curl/wget-like download functionality in urllib (like http offers server)

2021-10-19 Thread Chris Angelico
On Wed, Oct 20, 2021 at 1:23 AM Christian Heimes wrote: > > On 19/10/2021 00.06, Chris Angelico wrote: > > On Tue, Oct 19, 2021 at 9:00 AM Cameron Simpson wrote: > >> The problem with a "download()" method is that it is almost never what > >> you need. There are too many ways to want to do it, an

[Python-ideas] Re: Fwd: Simple curl/wget-like download functionality in urllib (like http offers server)

2021-10-19 Thread Tom Pohl
You are absolutely right, the functionality is there, but the idea is to make it easily available from the command line. Here is a line (with shortened URL) from a Dockerfile which installs poetry as suggested in the docs: RUN python -c "from urllib.request import urlopen; print(urlopen('h

[Python-ideas] Re: Fwd: Simple curl/wget-like download functionality in urllib (like http offers server)

2021-10-19 Thread Christian Heimes
On 19/10/2021 00.06, Chris Angelico wrote: On Tue, Oct 19, 2021 at 9:00 AM Cameron Simpson wrote: The problem with a "download()" method is that it is almost never what you need. There are too many ways to want to do it, and one almost _never_ wants to suck the download itself into memory as yo

[Python-ideas] Re: Fwd: Simple curl/wget-like download functionality in urllib (like http offers server)

2021-10-19 Thread Eric Fahlgren
On Tue, Oct 19, 2021 at 12:31 AM Tom Pohl wrote: > I am aware of requests (or httpx, ...), but the idea is to do all that > with the > standard library. If I have to install stuff, I could just install > wget/curl and be done. > I believe what you are looking for is already in the stdlib, see ur

[Python-ideas] Re: Real Positional Arguments or OO Currying

2021-10-19 Thread Mathew Elman
> Seems like the docs should cover that (or even `help()`) -- and if not, then > the parameter names could be better. It should, and normally does as do the parameters, but the best documentation should be the code itself, right? So the idea here would be to make it harder to not know the order

[Python-ideas] Re: Fwd: Simple curl/wget-like download functionality in urllib (like http offers server)

2021-10-19 Thread Tom Pohl
Performance is not an issue in the use case I envision. This is about downloading small installation scripts (i.e for install poetry in a container) or a few megabytes of data. I just tested the improved script (with just 1MB of read buffer) and it could easily saturate my 100 Mbit/s connection

[Python-ideas] Re: Fwd: Simple curl/wget-like download functionality in urllib (like http offers server)

2021-10-19 Thread Tom Pohl
I am aware of requests (or httpx, ...), but the idea is to do all that with the standard library. If I have to install stuff, I could just install wget/curl and be done. Feature creep is an issue here, but just like http.server one could be really strict about just covering 90% of the use cases