and deal with it in a uniform manner. Returned object is guaranteed
to have all the basic stdio read methods (read, readline, readlines).
Just .close() the object when you're done with it.
-
- Examples:
- >>> from xml.dom import minidom
- >>> sock = openAnything("http://localhost/kant.xml")
- >>> doc = minidom.parse(sock)
- >>> sock.close()
- >>> sock = openAnything("c:\\inetpub\\wwwroot\\kant.xml")
- >>> doc = minidom.parse(sock)
- >>> sock.close()
- >>> sock = openAnything("<ref id='conjunction'><text>and</text><text>or</text></ref>")
- >>> doc = minidom.parse(sock)
- >>> sock.close()
"""
if hasattr(source, "read"):
return source