def _fd(f):
 return (f.fileno() if hasattr(f, 'fileno') else f)

def _fd ( f ) : return ( f . fileno ( ) if hasattr ( f , 'fileno' ) else f )
get a filedescriptor from something which could be a file or an fd .