[Python-ideas] Re: Implementing a 'but' statement in for-iterations

2021-06-28 Thread Johnathan Irvin
What do we gain from this? Three characters. I'm not sure how useful this would be. On Mon, Jun 28, 2021, 9:29 PM David Mertz wrote: > Umm?! > > items = (j for j in range(10) if j not in {2, 8}) > > We don't need a new keyword. Nor a tortured use of an old one. > > On Mon, Jun 28, 2021, 8:46

[Python-ideas] Re: Implementing a 'but' statement in for-iterations

2021-06-28 Thread David Mertz
Umm?! items = (j for j in range(10) if j not in {2, 8}) We don't need a new keyword. Nor a tortured use of an old one. On Mon, Jun 28, 2021, 8:46 PM Rob Cliffe via Python-ideas < python-ideas@python.org> wrote: > Another wild idea: Suppose that after a line that introduces a suite, >

[Python-ideas] Re: Implementing a 'but' statement in for-iterations

2021-06-28 Thread Rob Cliffe via Python-ideas
Another wild idea:  Suppose that after a line that introduces a suite, including the final colon, you could write further lines on the same physical line, and this would be semantically equivalent to having them on separate lines with increasing indents, but a smaller indent than the following

[Python-ideas] Re: Implementing a 'but' statement in for-iterations

2021-06-28 Thread Richard Damon
On 6/28/21 5:40 PM, Max Shouman wrote: > This is more of a syntactic sugar than an actual new feature, but... > Exactly, 'but' is the idea: a special keyword to be used in for statements to > exclude values ​​from the iterable. > > E.g., when iterating over a generator: for i in range(0, 10)

[Python-ideas] Re: Implementing a 'but' statement in for-iterations

2021-06-28 Thread Chris Angelico
On Tue, Jun 29, 2021 at 7:51 AM Max Shouman wrote: > > This is more of a syntactic sugar than an actual new feature, but... > Exactly, 'but' is the idea: a special keyword to be used in for statements to > exclude values from the iterable. > > E.g., when iterating over a generator: > >>> for i

[Python-ideas] Implementing a 'but' statement in for-iterations

2021-06-28 Thread Max Shouman
This is more of a syntactic sugar than an actual new feature, but... Exactly, 'but' is the idea: a special keyword to be used in for statements to exclude values ​​from the iterable. E.g., when iterating over a generator: >>> for i in range(0, 10) but (2, 8): would implicitly create a new

[Python-ideas] Re: disallow assignment to unknown ssl.SSLContext attributes

2021-06-28 Thread Christian Heimes
On 28/06/2021 20.36, Brendan Barnwell wrote: > On 2021-06-28 07:03, Thomas Grainger wrote: >>> >but in this case the object is security sensitive, and security >>> should be much more rigorous in ensuring correctness. >> It looks like there's a consensus being reached, should I create a bpo? > >  

[Python-ideas] Re: disallow assignment to unknown ssl.SSLContext attributes

2021-06-28 Thread Thomas Grainger
Another problem with the assignment API is that the order the attributes are assigned is important: Eg check_hostname needs to be assigned before verify_mode or a warning is raised: https://github.com/encode/httpx/pull/1687/commits/ed9aabfeff6c18652db918bd0628c94d2513487a On Mon, 28 Jun 2021,

[Python-ideas] Re: disallow assignment to unknown ssl.SSLContext attributes

2021-06-28 Thread Brendan Barnwell
On 2021-06-28 07:03, Thomas Grainger wrote: >but in this case the object is security sensitive, and security should be much more rigorous in ensuring correctness. It looks like there's a consensus being reached, should I create a bpo? If we're going to make backwards-incompatible changes to

[Python-ideas] Re: joining paths without worrying about a leading slash

2021-06-28 Thread Zbigniew Jędrzejewski-Szmek
On Mon, Jun 28, 2021 at 10:03:15AM -0400, Wes Turner wrote: > Here's this, which IIRC I never wrote tests for, which is what needs to be > done to specify the correct behavior: > > ```python > def pathjoin(*args, **kwargs): > """ > Arguments: > args (list): *args list of paths >

[Python-ideas] Re: disallow assignment to unknown ssl.SSLContext attributes

2021-06-28 Thread Thomas Grainger
httpx.create_ssl_context() is one such utility function python -m pip install httpx python >>> import httpx >>> ctx = httpx.create_ssl_context() Ironically the context returned doesn't support ctx.minimum_version assignment due to another hangnail in the ssl.SSLContext API! This is fixed

[Python-ideas] Re: disallow assignment to unknown ssl.SSLContext attributes

2021-06-28 Thread Jonathan Fine
Thomas Grainger wrote: It looks like there's a consensus being reached, should I create a bpo? > Perhaps first state what seems to be the consensus and invite further comments before going to bpo. Disclaimer: I'd like to see both: 1. Something on PyPi to help persons who are using ssl on

[Python-ideas] Re: joining paths without worrying about a leading slash

2021-06-28 Thread Wes Turner
Here's this, which IIRC I never wrote tests for, which is what needs to be done to specify the correct behavior: ```python def pathjoin(*args, **kwargs): """ Arguments: args (list): *args list of paths if len(args) == 1, args[0] is not a string, and args[0] is

[Python-ideas] Re: disallow assignment to unknown ssl.SSLContext attributes

2021-06-28 Thread Thomas Grainger
> but in this case the object is security sensitive, and security should be > much more rigorous in ensuring correctness. It looks like there's a consensus being reached, should I create a bpo? Thomas Grainger On Sat, 26 Jun 2021 at 23:03, Ethan Furman wrote: > > On 6/26/21 1:55 PM, Marc-Andre

[Python-ideas] Re: joining paths without worrying about a leading slash

2021-06-28 Thread Zbigniew Jędrzejewski-Szmek
On Sun, Jun 27, 2021 at 09:55:34PM -0400, Wes Turner wrote: > "[Python-ideas] Sanitize filename (path part) 2nd try" > https://mail.python.org/archives/list/python-ideas@python.org/thread/LRIKMG3G4I4YQNK6BTU7MICHT7X67MEF/ > > "[Python-ideas] Sanitize filename (path part)" >

[Python-ideas] Re: joining paths without worrying about a leading slash

2021-06-28 Thread Zbigniew Jędrzejewski-Szmek
On Sun, Jun 27, 2021 at 10:13:25PM +0100, Barry Scott wrote: > > > On 27 Jun 2021, at 12:07, Zbigniew Jędrzejewski-Szmek > > wrote: > > > > [this is a continuation of https://bugs.python.org/issue44452] > > > > pathlib.Path() has a concatenation operator "/" that allows the > >