Bhoomika Sheth
Bhoomika Sheth

Reputation: 333

What does h = httplib2.Http('.cache') mean?

What does line 2 (h = httplib2.Http('.cache')) mean here?

>>> import httplib2
>>> h = httplib2.Http('.cache')

Upvotes: 2

Views: 2413

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1123420

From the httplib2.HTTP() documentation string:

If 'cache' is a string then it is used as a directory name for a disk cache. Otherwise it must be an object that supports the same interface as FileCache.

The line creates an instance of the HTTP() class, and sets the cache parameter to .cache, meaning that a .cache directory in the current working directory is used for cached data.

From the Usage section of the project documentation you can see that the cache is used to cache responses according to HTTP caching rules; the cache will honour cache headers set on the response unless you override those headers with corresponding request headers.

Upvotes: 7

Related Questions