Re: [Python-ideas] Typecheckers: there can be only one

2016-09-09 Thread Hugh Fisher
> From: Steven D'Aprano > > I fear that you haven't grasped the fundamental difference between > gradual static typing of a dynamically-typed language like Python, and > non-gradual typing of statically-typed languages like C, Haskell, Java, > etc. Your statement seems like a reasonable fear if yo

[Python-ideas] Expose reasons for SSL/TLS cert verification failures

2016-09-09 Thread Chi Hsuan Yen
Hi Python enthusiasts, Currently _ssl.c always reports CERTIFICATE_VERIFY_FAILED for any certification verification errors. In OpenSSL, it's possible to tell from different reasons that lead to CERTIFICATE_VERIFY_FAILED. For example, https://expired.badssl.com/ reports X509_V_ERR_CERT_HAS_EXPIRED,

Re: [Python-ideas] Expose reasons for SSL/TLS cert verification failures

2016-09-09 Thread Christian Heimes
On 2016-09-09 12:23, Chi Hsuan Yen wrote: > Hi Python enthusiasts, > > Currently _ssl.c always reports CERTIFICATE_VERIFY_FAILED for any > certification verification errors. In OpenSSL, it's possible to tell > from different reasons that lead to CERTIFICATE_VERIFY_FAILED. For > example, https://ex

Re: [Python-ideas] Changing optimisation level from a script

2016-09-09 Thread Guido van Rossum
What is to stop you from adding this to micropython as a library extension? I've never felt the urge to do this and I don't think I've ever heard it requested before. If you think it should be in the stdlib, given the timing of the 3.6 feature freeze the earliest time it could land would be Python

Re: [Python-ideas] Expose reasons for SSL/TLS cert verification failures

2016-09-09 Thread Chi Hsuan Yen
On Sat, Sep 10, 2016 at 1:16 AM, Christian Heimes wrote: > On 2016-09-09 12:23, Chi Hsuan Yen wrote: > > Hi Python enthusiasts, > > > > Currently _ssl.c always reports CERTIFICATE_VERIFY_FAILED for any > > certification verification errors. In OpenSSL, it's possible to tell > > from different rea

Re: [Python-ideas] Changing optimisation level from a script

2016-09-09 Thread Brett Cannon
On Thu, 8 Sep 2016 at 21:36 Damien George wrote: > Hi all, > > When starting CPython from the command line you can pass the -O option > to enable optimisations (eg `assert 0` won't raise an exception when > -O is passed). But, AFAIK, there is no way to change the optimisation > level after the i

Re: [Python-ideas] Changing optimisation level from a script

2016-09-09 Thread Guido van Rossum
I very much doubt that one assert might depend on another, and if they do, we can just tell people not to change the debug level. The API to change this should set __debug__ appropriately. On Fri, Sep 9, 2016 at 10:20 AM, Brett Cannon wrote: > > > On Thu, 8 Sep 2016 at 21:36 Damien George wrote:

[Python-ideas] Null coalescing operator

2016-09-09 Thread Arek Bulski
Sometimes I find myself in need of this nice operator that I used back in the days when I was programming in .NET, essentially an expression >>> expr ?? instead should return expr when it `is not None` and `instead` otherwise. A piece of code that I just wrote, you can see a use case: def _

Re: [Python-ideas] Null coalescing operator

2016-09-09 Thread Chris Angelico
On Sat, Sep 10, 2016 at 6:01 AM, Arek Bulski wrote: > Sometimes I find myself in need of this nice operator that I used back in > the days when I was programming in .NET, essentially an expression > expr ?? instead > > should return expr when it `is not None` and `instead` otherwise. You can

Re: [Python-ideas] Null coalescing operator

2016-09-09 Thread Zachary Ware
On Fri, Sep 9, 2016 at 3:01 PM, Arek Bulski wrote: > Sometimes I find myself in need of this nice operator that I used back in > the days when I was programming in .NET, essentially an expression > expr ?? instead > > should return expr when it `is not None` and `instead` otherwise. > > A pie

Re: [Python-ideas] Null coalescing operator

2016-09-09 Thread David Mertz
This idea has come up before. While I can see the use of it, to me at least that use doesn't feel nearly common enough to warrant dedicated syntax. In many cases, it is a "truthy" value you are looking for rather than `is not None` specifically. That has a convenient spelling: expr or instead

Re: [Python-ideas] Null coalescing operator

2016-09-09 Thread David Mertz
I'd note you can also save 4 characters by writing: instead if expr is None else expr On Fri, Sep 9, 2016 at 1:10 PM, David Mertz wrote: > This idea has come up before. While I can see the use of it, to me at > least that use doesn't feel nearly common enough to warrant dedicated > syntax. >

Re: [Python-ideas] Null coalescing operator

2016-09-09 Thread MRAB
On 2016-09-09 21:01, Arek Bulski wrote: Sometimes I find myself in need of this nice operator that I used back in the days when I was programming in .NET, essentially an expression expr ?? instead should return expr when it `is not None` and `instead` otherwise. A piece of code that I just w

Re: [Python-ideas] Changing optimisation level from a script

2016-09-09 Thread Damien George
> What is to stop you from adding this to micropython as a library > extension? That's what I would like to do, and usually we do just go ahead and add our own extensions, trying to be Pythonic as possible :) But we do that a lot and sometimes I think it would be good to discuss with upstream (ie

Re: [Python-ideas] Changing optimisation level from a script

2016-09-09 Thread MRAB
On 2016-09-10 01:04, Damien George wrote: What is to stop you from adding this to micropython as a library extension? That's what I would like to do, and usually we do just go ahead and add our own extensions, trying to be Pythonic as possible :) But we do that a lot and sometimes I think it w

Re: [Python-ideas] Null coalescing operator

2016-09-09 Thread Steven D'Aprano
On Fri, Sep 09, 2016 at 10:01:44PM +0200, Arek Bulski wrote: > Sometimes I find myself in need of this nice operator that I used back in > the days when I was programming in .NET, essentially an expression > > >>> expr ?? instead > > should return expr when it `is not None` and `instead` otherwis

Re: [Python-ideas] Changing optimisation level from a script

2016-09-09 Thread Steven D'Aprano
On Sat, Sep 10, 2016 at 10:04:46AM +1000, Damien George wrote: > I guess my main question to this list is: if CPython were to add a > function to change the optimisation level at runtime, what would it > look like? I don't think it would look like sys.optimize(flag). At the very least, it would

Re: [Python-ideas] Changing optimisation level from a script

2016-09-09 Thread Andrew Svetlov
There are also peephole optimization. Removing it may prevent false positives for coverage tool http://bugs.python.org/issue2506 On Sat, Sep 10, 2016 at 4:01 AM Steven D'Aprano wrote: > On Sat, Sep 10, 2016 at 10:04:46AM +1000, Damien George wrote: > > > I guess my main question to this list is: