79499245

Date: 2025-03-10 22:05:32
Score: 1
Natty:
Report link
def is_installed(pkg):
    try:
        __import__(pkg)
        return True
    except ImportError:
        return False

if is_installed("foo"):
    print("Foo installed")
else:
    print("Foo not installed")

This code defines a function that checks if a package is installed using __import__

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: mani agah smailzad