2016-12-08 | Paul Boddie | file changeset files shortlog | Added support for fopen and opening files. Moved common stream functionality into the __builtins__.file module. Moved common type checking functionality into the __builtins__.types module. |
paul@347 | 1 | try: |
paul@347 | 2 | f = open("tests/read_file.py") # this file! |
paul@347 | 3 | except IOError, exc: |
paul@347 | 4 | print "I/O error occurred:", exc.value |
paul@347 | 5 | raise |
paul@347 | 6 | |
paul@347 | 7 | try: |
paul@347 | 8 | s = f.read(5) |
paul@347 | 9 | print s # try: |
paul@347 | 10 | s = f.read(49) |
paul@347 | 11 | print s # f = open("tests/read_file.py") # this file! |
paul@347 | 12 | s = f.read() |
paul@347 | 13 | print s |
paul@347 | 14 | finally: |
paul@347 | 15 | f.close() |