[Python-ideas] Contracts in python -- a report & next steps

Anders Hovmöller boxed at killingar.net
Wed Oct 24 05:34:51 EDT 2018


> Roadblocks
> During the development, the following roadblocks were encountered:
> 
> * We wanted to include the contracts in the output of help(). Unfortunately, help() renders the __doc__ of the class and not of the instance. For functions, this is the class "function" which you can not inherit from. See [5] for more details.
> 
> * We need to inspect the source code of the condition and error lambdas to generate the violation message and infer the error type in the documentation, respectively. inspect.getsource(.) is broken on lambdas defined in decorators in Python 3.5.2+ (see [6]). 


Both these things seem like we should look at separately! I know I'm always annoyed that repr(lambda x: x*2) != "lambda x: x*2" for some reason. Fixing these two things in python seems like obvious wins to me, especially the latter.

/ Anders
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181024/389f8e6f/attachment.html>


More information about the Python-ideas mailing list