Changeset 727 for hodgestar/Talks/PythonForProgrammers/slides/py4prog.py
- Timestamp:
- 03/05/10 21:38:58 (2 years ago)
- Location:
- hodgestar/Talks/PythonForProgrammers
- Files:
-
- 2 modified
-
. (modified) (1 prop)
-
slides/py4prog.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hodgestar/Talks/PythonForProgrammers
-
Property
svn:ignore set
to
_*
-
Property
svn:ignore set
to
-
hodgestar/Talks/PythonForProgrammers/slides/py4prog.py
r726 r727 84 84 85 85 Slide("Course Structure", 86 Bullet("First Script:", PYCODE( '''86 Bullet("First Script:", PYCODE(r''' 87 87 #!/usr/bin/env python 88 88 … … 111 111 112 112 Slide("Numeric and Sequence Types", 113 Bullet("Numeric types:", PYCON( '''113 Bullet("Numeric types:", PYCON(r''' 114 114 >>> 5, 12345678901234567890123 115 115 (5, 12345678901234567890123L) … … 135 135 ), 136 136 137 Slide("File Handling and Iterables", 138 Bullet("text2.py:", PYCODE(r''' 139 def main(args): 140 prog = args[0] 141 filenames = args[1:] 142 143 for filename in filenames: 144 f = open(filename, "rb") 145 146 try: 147 for line in sorted(f): 148 print line, 149 finally: 150 f.close() 151 152 with open(filename, "rb") as f: 153 for i, line in enumerate(sorted(f)): 154 print "%3d: %s" % (i, line), 155 156 with open(filename, "rU") as f: 157 print f.read().replace("\n", r" \\ ") 158 ''')), 159 ), 160 137 161 ) 138 162
