def get_code_object(x):
if hasattr(x, '<STR_LIT>'): <EOL><INDENT>x = x.__func__<EOL><DEDENT>if hasattr(x, '<STR_LIT>'): <EOL><INDENT>x = x.__code__<EOL><DEDENT>if hasattr(x, '<STR_LIT>'):  <EOL><INDENT>x = x.gi_code<EOL><DEDENT>if isinstance(x, str):     <EOL><INDENT>x = _try_compile(x, "<STR_LIT>")<EOL><DEDENT>if hasattr(x, '<STR_LIT>'):  <EOL><INDENT>return x<EOL><DEDENT>raise TypeError("<STR_LIT>" %<EOL>type(x).__name__)<EOL>
Helper to handle methods, functions, generators, strings and raw code objects