Skip to content

Instantly share code, notes, and snippets.

@briandigital
Created March 3, 2014 15:29
Show Gist options
  • Save briandigital/9327380 to your computer and use it in GitHub Desktop.
Save briandigital/9327380 to your computer and use it in GitHub Desktop.
Python Interactive Interpreter in a HEREDOC in a BBEdit UNIX Worksheet
# How to use the Python Interactive Interpreter with a BBEdit UNIX Worksheet.
# Thanks to @bbedit_hints for suggesting this.
# Disclaimer: the author of this file doesn't know a damn thing about HEREDOC so proceed at your own risk.
# Step 1: call Python, then double angle brackets, space, "HERE" to open the HEREDOC:
python << HERE
#Step 2: write the Python you want interpreted:
def biggest(a,b,c): #outputs the largest
if (a > b) and (a > c):
return a
else:
if (b > a) and (b > c):
return b
else: return c
print biggest(3, 6, 9)
# Step 3: close the HEREDOC with a "HERE" below your Python code
# Step 4: Select all the text you want executed by BBEdit through the shell, press "Enter" or "CMD+Return" to execute
# In our case, that means from the "python" to the final "HERE" below.
# If this works right, "9" will appear below the closing "HERE" below…
HERE
9
# Worked!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment