Skip to content

Commit 754e463

Browse files
committed
Add wrapper to allow iterating over formats() in Python SDK
1 parent 57f0d48 commit 754e463

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

python/e2b_code_interpreter/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ def __init__(self, is_main_result: bool, data: [MIMEType, str]):
7979
self.javascript = data.pop("application/javascript", None)
8080
self.extra = data
8181

82+
# Allows to iterate over formats()
83+
def __getitem__(self, item):
84+
if item in self.raw:
85+
return self.raw[item]
86+
return getattr(self, item)
87+
8288
def formats(self) -> Iterable[str]:
8389
"""
8490
Returns all available formats of the result.

0 commit comments

Comments
 (0)