mirror of
https://github.com/kennethreitz/python-guide.git
synced 2026-06-05 23:00:18 +00:00
Merge pull request #117 from guibog/master
Adding some explanation to style guide
This commit is contained in:
@@ -261,6 +261,9 @@ keep a count of your place in the list.
|
|||||||
# 1, 4
|
# 1, 4
|
||||||
# 2, 5
|
# 2, 5
|
||||||
|
|
||||||
|
The ``enumerate`` function has better readability than handling a counter manually. Moreover,
|
||||||
|
it is better optimized for iterators.
|
||||||
|
|
||||||
Read From a File
|
Read From a File
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
@@ -284,6 +287,9 @@ files for you.
|
|||||||
for line in f:
|
for line in f:
|
||||||
print line
|
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
|
Returning Multiple Values from a Function
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user