summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDivay Prakash <divayprakash@users.noreply.github.com>2018-09-08 18:42:09 +0530
committerGitHub <noreply@github.com>2018-09-08 18:42:09 +0530
commite6c27bb8201e43585f53c3adc8cb8c6acae916fa (patch)
tree709fb3f5967fc33439dd94e1332554399f084322
parentd67d50793e8f67d460386483f659ecc219f8e523 (diff)
parentbb18dc81548a68b25227306bead977d55da23c66 (diff)
Merge pull request #3081 from thalesmello/patch-1
[pythonstatcomp/en] Improvements to syntax and comments
-rw-r--r--pythonstatcomp.html.markdown14
1 files changed, 6 insertions, 8 deletions
diff --git a/pythonstatcomp.html.markdown b/pythonstatcomp.html.markdown
index 66eeb7ad..2440d859 100644
--- a/pythonstatcomp.html.markdown
+++ b/pythonstatcomp.html.markdown
@@ -38,18 +38,16 @@ r.text # raw page source
print(r.text) # prettily formatted
# save the page source in a file:
os.getcwd() # check what's the working directory
-f = open("learnxinyminutes.html", "wb")
-f.write(r.text.encode("UTF-8"))
-f.close()
+with open("learnxinyminutes.html", "wb") as f:
+ f.write(r.text.encode("UTF-8"))
# downloading a csv
fp = "https://raw.githubusercontent.com/adambard/learnxinyminutes-docs/master/"
fn = "pets.csv"
r = requests.get(fp + fn)
print(r.text)
-f = open(fn, "wb")
-f.write(r.text.encode("UTF-8"))
-f.close()
+with open(fn, "wb") as f:
+ f.write(r.text.encode("UTF-8"))
""" for more on the requests module, including APIs, see
http://docs.python-requests.org/en/latest/user/quickstart/
@@ -71,8 +69,8 @@ pets
# 1 vesuvius 6 23 fish
# 2 rex 5 34 dog
-""" R users: note that Python, like most normal programming languages, starts
- indexing from 0. R is the unusual one for starting from 1.
+""" R users: note that Python, like most C-influenced programming languages, starts
+ indexing from 0. R starts indexing at 1 due to Fortran influence.
"""
# two different ways to print out a column