Select Page

Exception handling

try:
  # Do something
except Exception as e:
  # Handle it

Print array of strings

print ""\n"".join(arr)

Iterating by index

for i in range(len(arr)):
  print arr[i]

Passing CLI arguments

import sys
print(sys.argv[0])

Using env variables

import os
print(os.environ)

print(os.environ.get('SECRET_API_KEY'))
os.environ['OUTPUT_FORMAT'] = 'format-one'