Skip to content

Commit ab866cd

Browse files
author
Kenneth Reitz
committed
Merge pull request realpython#117 from guibog/master
Adding some explanation to style guide
2 parents 87a7942 + 6e9b37c commit ab866cd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/writing/style.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ keep a count of your place in the list.
261261
# 1, 4
262262
# 2, 5
263263
264+
The ``enumerate`` function has better readability than handling a counter manually. Moreover,
265+
it is better optimized for iterators.
266+
264267
Read From a File
265268
----------------
266269

@@ -284,6 +287,9 @@ files for you.
284287
for line in f:
285288
print line
286289
290+
The ``with`` statement is better because it will ensure you always close the file,
291+
even if an exception is raised.
292+
287293
Returning Multiple Values from a Function
288294
-----------------------------------------
289295

0 commit comments

Comments
 (0)