Initial commit

This commit is contained in:
Justin C. Miller
2025-05-10 18:22:53 -07:00
commit fe6aa0ff01
6 changed files with 100 additions and 0 deletions

42
pyinfo.py Normal file
View File

@@ -0,0 +1,42 @@
import sys
import click
def print_list(name, l):
print(f"{name}:")
for v in l: print("\t", v)
print()
def print_dict(name, d):
print(f"{name}:")
for k, v in d.items():
print(f"\t{k:10}: {v}")
print()
sys_vars = (
"path",
"meta_path",
"orig_argv",
"executable",
"version",
#"implementation",
"prefix",
"_is_gil_enabled",
)
@click.command()
def info():
"""Show info about the current python environment."""
for var in sys_vars:
name = f"sys.{var}"
value = getattr(sys, var)
if callable(value):
value = value()
name += "()"
if isinstance(value, list): print_list(name, value)
elif isinstance(value, dict): print_dict(name, value)
else: print(f"{name:25}: {value}")
if __name__ == "__main__":
info()