On Sun, Oct 31, 2021 at 4:50 AM Eric V. Smith <e...@trueblade.com> wrote: > > On 10/30/2021 10:40 AM, Chris Angelico wrote: > > And, seeing something in help(fn) largely necessitates that the source > > code be retained. I don't know of any other way to do it. If you say > > that the default argument is "len(a)", then that's what help() should > > say. > > "from __future__ import annotations" works by decompiling the AST into a > string. From PEP 563: "The string form is obtained from the AST during > the compilation step, which means that the string form might not > preserve the exact formatting of the source." > > I'm not saying this is a better way to do it, but it is another way. And > it might save some memory. I don't think the slight differences > mentioned at the end of that sentence would make a difference in practice. >
Thank you Eric for pointing this out, and a big thank you to Lukasz and everyone else who implemented this. I allocated a couple of hours to figuring out how to get source representations of late-bound defaults, started up a livestream, and in about fifteen minutes, had deployed and tested something that uses _PyAST_ExprAsUnicode to do the whole job. Was able to settle that and then move on to other things. Thank you for making my life easier! ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3TJOOQOEHGIIHATBLIT4L5JVOMESBWBZ/ Code of Conduct: http://python.org/psf/codeofconduct/