Skip to content

Instantly share code, notes, and snippets.

@tchen
Created June 18, 2015 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tchen/ed9f319c2c5736a8e985 to your computer and use it in GitHub Desktop.
Save tchen/ed9f319c2c5736a8e985 to your computer and use it in GitHub Desktop.
Helpful functions
# Tuple abs val
def tup_abs(t):
return math.sqrt(t[0]*t[0] + t[1]*t[1] + t[2]*t[2])
# Look for attributes of an object
# Find s in attributes of o
def find_attr(o, s):
import re
regex = re.compile(r'.*'+s+'.*')
return [ at for at in dir(o) if regex.match(at) is not None ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment