python3: 'module' object is not callable - type is <class 'http.client.HTTPResponse'>

Chris Angelico rosuav at gmail.com
Wed Dec 3 04:42:38 EST 2014


On Tue, Dec 2, 2014 at 6:45 AM, Chris Cioffi <chris at evenprimes.com> wrote:
>   File "/Users/chris/dev/LendingClub/lendingclub.py", line 40, in _make_api_call
>     pprint(lcresponse.read())
> TypeError: 'module' object is not callable
>
> The relevant code is as follows:
> lcrequest = urllib.request.Request(url, data, {"Authorization": authorizationKey})
> lcresponse = urllib.request.urlopen(lcrequest)
>
> Any ideas on what I should be looking for?  Based on the docs and examples I would expect this to work.

Your problem isn't with urllib, but with pprint. The pprint module
exposes a function called pprint; you can use it either like this:

from pprint import pprint
pprint(some_object)

Or like this:

import pprint
pprint.pprint(some_object)

It looks like you're mixing and matching the two forms.

All the best!

ChrisA



More information about the Python-list mailing list