git://git.eng.unimelb.edu.au
/
python-guide.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
87a7942
)
add some explanations to style guide
author
guibog
<guibog@douban.com>
Sat, 21 Apr 2012 10:15:10 +0000
(18:15 +0800)
committer
guibog
<guibog@douban.com>
Sat, 21 Apr 2012 10:15:10 +0000
(18:15 +0800)
docs/writing/style.rst
patch
|
blob
|
history
diff --git
a/docs/writing/style.rst
b/docs/writing/style.rst
index
dbe4d9b
..
cc2e8c9
100644
(file)
--- a/
docs/writing/style.rst
+++ b/
docs/writing/style.rst
@@
-261,6
+261,9
@@
keep a count of your place in the list.
# 1, 4
# 2, 5
+The ``enumerate`` function has better readability than handling a counter manually. Moreover,
+it is better optimized for iterators.
+
Read From a File
----------------
@@
-284,6
+287,9
@@
files for you.
for line in f:
print line
+The ``with`` statement is better because it will ensure you always close the file,
+even if an exception is raised.
+
Returning Multiple Values from a Function
-----------------------------------------