Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book

#242: from lib import * but less

Published Thu, Jul 15, 2021, recorded Thu, Jul 15, 2021

Watch the live stream:

Watch this episode on YouTube
Play on YouTube
Watch the live stream replay

About the show

Sponsored by us:

Special guest: Al Sweigart

Brian #1: just

  • From a tweet by Jeff Triplett
  • just is a handy way to save and run project-specific commands.
  • Commands, called recipes, are stored in a file called justfile with syntax inspired by make
  • Just is a command runner, not a build system, so it avoids much of Make’s complexity and idiosyncrasies. No need for .PHONY recipes!
  • Linux, MacOS, and Windows are supported with no additional dependencies.”
  • It’s written in Rust.
  • My favorite differences:
    • a couple spaces is fine, no need for tabs
    • Recipes can accept command line arguments
    • Recipes can be listed from the command line.
    • Recipes can be written in arbitrary languages,
      like Python
          hello:
            echo "Hello World!"
      
          pyhello:
            #!/usr/bin/env python3
            print('Hello from python!')
      

Michael #2: Strong Typing

  • via Roman Right (Beanie)
  • Decorator which checks whether the function is called with the correct type of parameters.
  • Decorator which checks at Runtime whether the function is called with the correct type of parameters.
  • Raises TypeMisMatch if the used parameters in a function call where invalid.

Al #3:

Brian #4: testbook

Michael #5: auto-all

  • Automatically manage the __all__ variable in Python modules.
    • Easily populate the __all__ variable in modules.
    • Easily exclude imported objects
    • Clearly differentiate between internal and external facing objects.
    • Use simple, intuitive code.
    • Never worry about forgetting to add new objects to __all__.
    • Help Python IDE's differentiate between internal and external facing objects.
  • Can use “regions” via start_all() and end_all()
  • I prefer the decorator (functions only, seems ripe for a PR for classes)
        @public
        def a_public_function():
            pass
    

Al #6:

  • Next book: Untitled Recursion Book

Extras

Michael:

Al


Want to go deeper? Check our projects