def debug_element(obj): """Get all attributes and their string representations from an object using dir().""" import copy try: # Create a deep copy of the object if possible obj_copy = copy.deepcopy(obj) except: try: # If deepcopy fails, try shallow copy obj_copy = copy.copy(obj) except: # If copying fails completely, use the original object obj_copy = obj attributes = dir(obj_copy) results = [] for attr in attributes: try: # Get the attribute value from the copy value = getattr(obj_copy, attr) # Handle callable attributes if callable(value): try: # Try to call the method without arguments result = value() str_value = f"" except Exception as call_error: # If calling fails, just record it's a callable str_value = f"" else: str_value = str(value) results.append(f"{attr}: {str_value}") except Exception as e: results.append(f"{attr}: ") return results