def fsencoding(s, encoding=sys.getfilesystemencoding()):
 if isinstance(s, unicode):
  s = s.encode(encoding)
 return s

def fsencoding ( s , encoding = sys . getfilesystemencoding ( ) ) : if isinstance ( s , unicode ) : s = s . encode ( encoding ) return s
ensure the given argument is in filesystem encoding .