Skip to content
Myr

Remove explicit unicode literal in README.md and doc (#5336)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* [remove] remove "u" prefix in README and documentation examples

authored by Alessio Izzo · committed by GitHub · parent 2758124 · Browse files · 4 files+17 added−17 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+17 added−17 removed

  • other:+17 added−17 removed

4 files+17 added−17 removed

modified:docs/user/advanced.rst+11 added-11 removed
696 unmodified lines
697698 >>> commit_data = r.json()699700 >>> print(commit_data.keys())701 [u'committer', u'author', u'url', u'tree', u'sha', u'parents', u'message']701 ['committer', 'author', 'url', 'tree', 'sha', 'parents', 'message']702703 >>> print(commit_data[u'committer'])704 {u'date': u'2012-05-10T11:10:50-07:00', u'email': u'me@kennethreitz.com', u'name': u'Kenneth Reitz'}703 >>> print(commit_data['committer'])704 {'date': '2012-05-10T11:10:50-07:00', 'email': 'me@kennethreitz.com', 'name': 'Kenneth Reitz'}705706 >>> print(commit_data[u'message'])706 >>> print(commit_data['message'])707 makin' history708709So far, so simple. Well, let's investigate the GitHub API a little bit. Now,710we could look at the documentation, but we might have a little more fun if we
34 unmodified lines
745 200746747 >>> issue = json.loads(r.text)748749 >>> print(issue[u'title'])749 >>> print(issue['title'])750 Feature any http verb in docs751752 >>> print(issue[u'comments'])752 >>> print(issue['comments'])753 3754755Cool, we have three comments. Let's take a look at the last of them.756757::758759 >>> r = requests.get(r.url + u'/comments')759 >>> r = requests.get(r.url + '/comments')760 >>> r.status_code761 200762763 >>> comments = r.json()764765 >>> print(comments[0].keys())766 [u'body', u'url', u'created_at', u'updated_at', u'user', u'id']766 ['body', 'url', 'created_at', 'updated_at', 'user', 'id']767768 >>> print(comments[2][u'body'])768 >>> print(comments[2]['body'])769 Probably in the "advanced" section770771Well, that seems like a silly place. Let's post a comment telling the poster772that he's silly. Who is the poster, anyway?773774::775776 >>> print(comments[2][u'user'][u'login'])776 >>> print(comments[2]['user']['login'])777 kennethreitz778779OK, so let's tell this Kenneth guy that we think this example should go in the780quickstart guide instead. According to the GitHub API doc, the way to do this
21 unmodified lines
802 >>> r.status_code803 201804805 >>> content = r.json()806 >>> print(content[u'body'])806 >>> print(content['body'])807 Sounds great! I'll get right on it.808809Brilliant. Oh, wait, no! I meant to add that it would take me a while, because810I had to go feed my cat. If only I could edit this comment! Happily, GitHub
222 unmodified lines
modified:docs/user/quickstart.rst+2 added-2 removed
91 unmodified lines
92 >>> import requests9394 >>> r = requests.get('https://api.github.com/events')95 >>> r.text96 u'[{"repository":{"open_issues":0,"url":"https://github.com/...96 '[{"repository":{"open_issues":0,"url":"https://github.com/...9798Requests will automatically decode content from the server. Most unicode99charsets are seamlessly decoded.100
46 unmodified lines
147 >>> import requests148149 >>> r = requests.get('https://api.github.com/events')150 >>> r.json()151 [{u'repository': {u'open_issues': 0, u'url': 'https://github.com/...151 [{'repository': {'open_issues': 0, 'url': 'https://github.com/...152153In case the JSON decoding fails, ``r.json()`` raises an exception. For example, if154the response gets a 204 (No Content), or if the response contains invalid JSON,155attempting ``r.json()`` raises ``ValueError: No JSON object could be decoded``.
410 unmodified lines
modified:docs/index.rst+2 added-2 removed
33 unmodified lines
34 'application/json; charset=utf8'35 >>> r.encoding36 'utf-8'37 >>> r.text38 u'{"type":"User"...'38 '{"type":"User"...'39 >>> r.json()40 {u'private_gists': 419, u'total_private_repos': 77, ...}40 {'private_gists': 419, 'total_private_repos': 77, ...}4142See `similar code, sans Requests <https://gist.github.com/973705>`_.4344
92 unmodified lines
modified:README.md+2 added-2 removed