Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Very briefly, it first parses the input code into an AST, then it converts the last node into a single line, and continuously "wraps" remaining nodes around this line mainly using lambdas until everything becomes one line. The source code is available for anyone who is interested in the nitty-gritty :)
Very cool. Also, Chelsea Voss did this in 2016 with Python 2 (https://github.com/csvoss/onelinerizer) and did a great talk about it at PyCon (https://www.youtube.com/watch?v=DsUxuz_Rt8g) . She also has try/except working, maybe something similar to her solution would also work in Python 3.