Skip to content

Commit 6e9b37c

Browse files
author
guibog
committed
add some explanations to style guide
1 parent 87a7942 commit 6e9b37c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

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)