CLI tools hidden in the Python standard library

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

    The Python programming language

  • Not supporting multi-line statements is just because pdb doesn't bother to parse the statement to work out if it is an incomplete multi-line statement. That could be easily fixed (I have a prototype patch for that using `code.compile_command`).

    The scope problems are more fundamental:

    The pdb REPL calls[1] the exec builtin as `exec(code, frame.f_globals, frame.f_locals)`, which https://docs.python.org/3/library/functions.html#exec documents as:

    "If exec gets two separate objects as globals and locals, the code will be executed as if it were embedded in a class definition."

    And https://docs.python.org/3/reference/executionmodel.html#reso... documents that:

    "The scope of names defined in a class block is limited to the class block; it does not extend to the code blocks of methods - this includes comprehensions and generator expressions since they are implemented using a function scope."

    This is a fundamental limitation of `exec`. You can workaround it by only passing a single namespace dictionary to exec instead of passing separate globals and locals, which is what pdb's interact command does[2], but then it's ambiguous how to map changes to that dictionary back to the separate globals and locals dictionaries (pdb's interact command just discards any changes you make to the namespace). This too could be solved, but requires either brittle ast parsing or probably a PEP to add new functionality to exec. I'll file a bug against Python soon.

    [1]: https://github.com/python/cpython/blob/25a64fd28aaaaf2d21fae...

  • Python Fire

    Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.

  • The cli tool [fire](https://github.com/google/python-fire/blob/master/docs/guide...) has a nifty feature where it can generate a cli for any file for you.

    So random and math are somewhat usable that way

        $ python -m fire random uniform 0 1

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

    :pizza: Peer-to-peer file transfers in your browser

  • FYI: you can use https://file.pizza/ for sending the file outside the network.

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