Our great sponsors
-
nose-of-yeti
Provides an RSpec inspired dsl for python tests. Inspired by the yeti project found at http://github.com/fmeyer/yeti
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
A long time ago I stumbled upon (and contributed to) https://github.com/delfick/nose-of-yeti. The most delightful bit of cursed Python I’ve seen!
I did something similar to option 3 to make the default numeric "callable", since the dunder __call__ methods can't be overwritten for integer types. For example, in regular arithmetic notation, something like 6(7+8) could be read as 6*(7+8), but trying to do this in Python gives you `SyntaxWarning: 'int' object is not callable;`, since you're essentially trying to do a function call on the literal 6. The workaround was to use a custom codec to wrap all integer literals to give them the expected call behavior.
Repo if anyone is interested: https://github.com/ckw017/blursed
This was inspired by a way less silly usecase, future f-strings, which added f-string support to older versions of Python in a similar way using codecs: https://github.com/asottile-archive/future-fstrings
I did something similar to option 3 to make the default numeric "callable", since the dunder __call__ methods can't be overwritten for integer types. For example, in regular arithmetic notation, something like 6(7+8) could be read as 6*(7+8), but trying to do this in Python gives you `SyntaxWarning: 'int' object is not callable;`, since you're essentially trying to do a function call on the literal 6. The workaround was to use a custom codec to wrap all integer literals to give them the expected call behavior.
Repo if anyone is interested: https://github.com/ckw017/blursed
This was inspired by a way less silly usecase, future f-strings, which added f-string support to older versions of Python in a similar way using codecs: https://github.com/asottile-archive/future-fstrings
I've attempted something more crazy -- to make Python support multi-line lambda expression [1].
It's done with AST manipulation as well, but on a larger scale and completer functionalities.
[1] https://github.com/hsfzxjy/lambdex