• BatmanAoD@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      8 months ago

      How is that easier? It doesn’t look like it provides a list of which modules have a __name__ == "__main__" block.

      • nickwitha_k (he/him)@lemmy.sdf.org
        link
        fedilink
        arrow-up
        1
        ·
        8 months ago

        No. But, it does provide a list of all stdlib libraries and those, like gzip, that are intended to be compatible with the CLI tend to have explicit documentation showing usage (ex. https://docs.python.org/3/library/gzip.html) and provides any other contextual info related to using the library.

        Don’t get me wrong, grepping through the code is a great way of building skills needed as a professional. Really, I have to do this kind of thing multiple times every week at work. It is, however, also worth noting that Python only uses an “honor system” for public/private functions, methods, and classes so modules having an “if name == ‘main’” block doesn’t necessarily mean that they are appropriate to use as CLI tools. They might be but, without documentation to back it up, it’s an “at your own risk” situation.