Skip to content

Commit 59ea8ee

Browse files
committed
fix print formatting in example
1 parent 3cb7c53 commit 59ea8ee

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/getting_started.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@
1717
# Download a file
1818
downloaded = codebox.download("example.txt")
1919
content = downloaded.get_content() # Returns b"Hello from CodeBox!"
20+
print("Content:\n", content, sep="")
2021

2122
# List files
22-
files = codebox.list_files() # Returns list[RemoteFile]
23+
files = codebox.list_files()
24+
print("\nFiles:\n", "\n".join(f.__repr__() for f in files), sep="")
2325

2426
# 3. Package Management
2527
# Install packages
2628
codebox.install("pandas")
2729

2830
# List installed packages
2931
packages = codebox.list_packages()
32+
print("\nFirst 10 packages:\n", "\n".join(packages[:10]), sep="")
3033

3134
# 4. Variable Management
3235
# Execute code that creates variables
@@ -38,7 +41,7 @@
3841

3942
# Show all variables
4043
variables = codebox.show_variables()
41-
print(variables) # Shows dict with all variables and their values
44+
print("\nVariables:\n", "\n".join(f"{k}={v}" for k, v in variables.items()), sep="")
4245

4346
# 5. Plotting with Matplotlib
4447
plot_code = """
@@ -59,6 +62,8 @@
5962
import time
6063
time.sleep(1)
6164
"""):
65+
# will not print when using "local" as api_key
66+
# due to stdout being captured in the background
6267
print(chunk.content, end="")
6368

6469
# 7. Bash Commands
@@ -73,4 +78,4 @@
7378
# 8. Error Handling
7479
result = codebox.exec("1/0")
7580
if result.errors:
76-
print("Error occurred:", result.errors[0])
81+
print("\nError occurred:", result.errors[0])

0 commit comments

Comments
 (0)