Easier and more self documenting patterns for loading/saving Persistent
[python_utils.git] / misc_utils.py
index 4979a3c65bcb377b813b18868962297f80b0bd1d..669b3ef98a20d2b4144da67299c463f73ee46851 100644 (file)
@@ -1,6 +1,11 @@
 #!/usr/bin/env python3
 
+# © Copyright 2021-2022, Scott Gasch
+
+"""Miscellaneous utilities."""
+
 import os
+import sys
 
 
 def is_running_as_root() -> bool:
@@ -12,6 +17,13 @@ def is_running_as_root() -> bool:
     return os.geteuid() == 0
 
 
+def debugger_is_attached() -> bool:
+    """Return if the debugger is attached"""
+
+    gettrace = getattr(sys, 'gettrace', lambda: None)
+    return gettrace() is not None
+
+
 if __name__ == '__main__':
     import doctest