Download Python/train/3.13/exception-groups/modern_07.py from SwashBuckler001/idiombench: direct link, hf CLI and curl.
- Browser
- Download file 453 Bytes
-
https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.13/exception-groups/modern_07.py
- Command line
-
hf download hf://datasets/SwashBuckler001/idiombench/Python/train/3.13/exception-groups/modern_07.py
-
curl -L -o modern_07.py https://huggingface.co/datasets/SwashBuckler001/idiombench/resolve/main/Python/train/3.13/exception-groups/modern_07.py
453 Bytes
| import traceback | |
| def g(v): | |
| try: | |
| raise ValueError(v) | |
| except Exception as e: | |
| return e | |
| def f(): | |
| raise ExceptionGroup("eg", [g(1), g(2)]) | |
| try: | |
| f() | |
| except BaseException as e: | |
| eg = e | |
| for (i, (exc, tbs)) in enumerate(leaf_generator(eg)): | |
| print(f"\n=== Exception #{i+1}:") | |
| traceback.print_exception(exc) | |
| print(f"The complete traceback for Exception #{i+1}:") | |
| for tb in tbs: | |
| traceback.print_tb(tb) | |