[Python-ideas] "old" values in postconditions

Marko Ristin-Kaufmann marko.ristin at gmail.com
Tue Sep 25 13:54:30 EDT 2018


Hi James and Franklin,

getsource() definitely does not work. I tried for a long, long time to make
it work and finally gave up. I parse in icontract the whole file where the
lambda function resides and use asttokens to locate the node of the lambda
(along some tree traversing upwards and making assumptions where the
condition lambda lives).

Have a look at:

https://github.com/Parquery/icontract/blob/391d43005287831892b19dfdcbcfd3d48662c638/icontract/represent.py#L309

and
https://github.com/Parquery/icontract/blob/391d43005287831892b19dfdcbcfd3d48662c638/icontract/represent.py#L157


On Tue, 25 Sep 2018 at 19:48, James Lu <jamtlu at gmail.com> wrote:

> > I'm surprised you haven't found
> >    inspect.getsource(func)
>
> I did. That’s exactly what I was describing in the paragraph. It wouldn’t
> work in interactive mode and it includes everything on the same line of the
> lambda definition.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180925/d9465b48/attachment-0001.html>


More information about the Python-ideas mailing list