Created
June 18, 2015 16:10
-
-
Save tchen/ed9f319c2c5736a8e985 to your computer and use it in GitHub Desktop.
Helpful functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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