From 6b3e094d795c5ef02dd0524faab5388751007bf6 Mon Sep 17 00:00:00 2001 From: evilchili Date: Wed, 17 Jan 2024 22:37:53 -0800 Subject: [PATCH] fallback to globals() if tables.index does not define an attribute --- rolltable/tables.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rolltable/tables.py b/rolltable/tables.py index 7adbb68..ecace52 100644 --- a/rolltable/tables.py +++ b/rolltable/tables.py @@ -19,4 +19,9 @@ index = dict( def __getattr__(name: str) -> Any: - return index[name] + try: + return index[name] + except KeyError: + if name in globals(): + return globals()[name] + raise AttributeError(f"No such attribute: {name}")