def _findShebang(filename):
 with open(filename, 'rU') as f:
  if (f.read(2) == '#!'):
   exe = f.readline(1024).strip('\n')
   return exe

def _findShebang ( filename ) : with open ( filename , 'rU' ) as f : if ( f . read ( 2 ) == '#!' ) : exe = f . readline ( 1024 ) . strip ( '\n' ) return exe
look for a #! line .