Skip to content
Myr

Switch to using dict literals, it's 2017

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

authored by Alex Chan · committed by Alex Chan · parent 2c4849d · Browse files · 1 file+3 added−3 removed
This commit

State

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

Diff stats

1 file+3 added−3 removed

  • other:+3 added−3 removed

1 file+3 added−3 removed

modified:docs/user/advanced.rst+3 added-3 removed
434 unmodified lines
435You can assign a hook function on a per-request basis by passing a436``{hook_name: callback_function}`` dictionary to the ``hooks`` request437parameter::438439 hooks=dict(response=print_url)439 hooks={'response': print_url}440441That ``callback_function`` will receive a chunk of data as its first442argument.443
9 unmodified lines
453anything, nothing else is effected.454455Let's print some request method arguments at runtime::456457 >>> requests.get('http://httpbin.org', hooks=dict(response=print_url))457 >>> requests.get('http://httpbin.org', hooks={'response': print_url})458 http://httpbin.org459 <Response [200]>460461You can also assign hooks to a ``Session`` instance. The hook will then be462called on every request made to the session. For example::463464 >>> s = requests.Session()465 >>> s.hooks = dict(response=print_url)465 >>> s.hooks['response'].append(print_url)466 >>> s.get('http://httpbin.org')467 http://httpbin.org468 <Response [200]>469
552 unmodified lines