home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pytho152.zip / emx / lib / python1.5 / util.py < prev    next >
Text File  |  2000-08-10  |  649b  |  26 lines

  1. # Module 'util' -- some useful functions that don't fit elsewhere
  2.  
  3. # NB: These are now built-in functions, but this module is provided
  4. # for compatibility.  Don't use in new programs unless you need backward
  5. # compatibility (i.e. need to run with old interpreters).
  6.  
  7.  
  8. # Remove an item from a list.
  9. # No complaints if it isn't in the list at all.
  10. # If it occurs more than once, remove the first occurrence.
  11. #
  12. def remove(item, list):
  13.     if item in list: list.remove(item)
  14.  
  15.  
  16. # Return a string containing a file's contents.
  17. #
  18. def readfile(fn):
  19.     return readopenfile(open(fn, 'r'))
  20.  
  21.  
  22. # Read an open file until EOF.
  23. #
  24. def readopenfile(fp):
  25.     return fp.read()
  26.