Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81846

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

From Chris Cioffi <chris@evenprimes.com>
Subject python3: 'module' object is not callable - type is <class 'http.client.HTTPResponse'>
Date 2014-12-01 14:45 -0500
Newsgroups comp.lang.python
Message-ID <mailman.16520.1417593626.18130.python-list@python.org> (permalink)

Show all headers | View raw


I'm writing a little script that uses a REST API and I'm having a problem using urllib in Python 3.

I had the basics working in Python 2.7, but for reasons I'm not clear on I decided to update to Python 3.  (I'm in the early phases, so this isn't production by any stretch.)


Python version info:
sys.version_info(major=3, minor=4, micro=2, releaselevel='final', serial=0)

Type() info of return object from urllib.request.urlopen:
<class 'http.client.HTTPResponse'>

Traceback of error when trying to pprint() the object:
Traceback (most recent call last):
  File "./test.py", line 59, in <module>
    testGetAvailableCash(lc)
  File "./test.py", line 12, in testGetAvailableCash
    print(lc.available_cash(INVESTORID, AUTHKEY))
  File "/Users/chris/dev/LendingClub/lendingclub.py", line 49, in available_cash
    return self._make_api_call(''.join((BASE_ACCOUNT_URL, investorID, "/availablecash")), authorizationKey)[u'availableCash']
  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. 

Thanks!

Chris

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

python3: 'module' object is not callable - type is <class 'http.client.HTTPResponse'> Chris Cioffi <chris@evenprimes.com> - 2014-12-01 14:45 -0500

csiph-web