Mercurial > cpython-lru_cache-weakref
annotate Lib/lib-stdwin/filewin.py @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | 1940892d2fe3 |
| children |
| rev | line source |
|---|---|
| 5 | 1 # Module 'filewin' |
| 2 # File windows, a subclass of textwin (which is a subclass of gwin) | |
| 3 | |
| 4 import textwin | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
215
diff
changeset
|
5 import __builtin__ |
| 5 | 6 |
| 7 | |
| 8 # FILE WINDOW | |
| 9 | |
| 10 def open_readonly(fn): # Open a file window | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
215
diff
changeset
|
11 fp = __builtin__.open(fn, 'r') |
|
215
f61e7368def2
Use built-in file.read() instead of util.readfile().
Guido van Rossum <guido@python.org>
parents:
150
diff
changeset
|
12 w = textwin.open_readonly(fn, fp.read()) |
| 5 | 13 w.fn = fn |
| 14 return w | |
| 15 | |
| 16 def open(fn): # Open a file window | |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
215
diff
changeset
|
17 fp = __builtin__.open(fn, 'r') |
|
215
f61e7368def2
Use built-in file.read() instead of util.readfile().
Guido van Rossum <guido@python.org>
parents:
150
diff
changeset
|
18 w = textwin.open(fn, fp.read()) |
| 5 | 19 w.fn = fn |
| 20 return w |
