Skip to content

Commit

Permalink
fix print formatting in example
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Oct 30, 2024
1 parent 3cb7c53 commit 59ea8ee
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/getting_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@
# Download a file
downloaded = codebox.download("example.txt")
content = downloaded.get_content() # Returns b"Hello from CodeBox!"
print("Content:\n", content, sep="")

# List files
files = codebox.list_files() # Returns list[RemoteFile]
files = codebox.list_files()
print("\nFiles:\n", "\n".join(f.__repr__() for f in files), sep="")

# 3. Package Management
# Install packages
codebox.install("pandas")

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

# 4. Variable Management
# Execute code that creates variables
Expand All @@ -38,7 +41,7 @@

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

# 5. Plotting with Matplotlib
plot_code = """
Expand All @@ -59,6 +62,8 @@
import time
time.sleep(1)
"""):
# will not print when using "local" as api_key
# due to stdout being captured in the background
print(chunk.content, end="")

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

0 comments on commit 59ea8ee

Please sign in to comment.