Adding C-style for loops to Python for fun

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • nose-of-yeti

    Provides an RSpec inspired dsl for python tests. Inspired by the yeti project found at http://github.com/fmeyer/yeti

  • 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!

  • blursed

    Just because you can doesn't mean you should.

  • 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

  • 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.

    InfluxDB logo
  • future-fstrings

    Discontinued A backport of fstrings to python<3.6

  • 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

  • lambdex

    Write complicated anonymous functions beyond lambdas in Python.

  • 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

  • pyxl

    A Python extension for writing structured and reusable inline HTML.

  • pyxl4

    Extend Python syntax with HTML.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts