memory location repr for requests-client
authorKenneth Reitz <me@kennethreitz.com>
Wed, 17 Aug 2011 02:19:49 +0000 (22:19 -0400)
committerKenneth Reitz <me@kennethreitz.com>
Wed, 17 Aug 2011 02:19:49 +0000 (22:19 -0400)
requests/sessions.py

index 5f62a78fb047666a7d8bacc58016e84d54d8ff6a..f8a6883f20cd0e92a7a2b19124e116a9933d9965 100644 (file)
@@ -16,22 +16,26 @@ class Session(object):
     __attrs__ = ['headers', 'cookies', 'auth', 'timeout', 'proxies']
 
     def __init__(self, **kwargs):
+
         # Set up a CookieJar to be used by default
         self.cookies = cookielib.FileCookieJar()
+
         # Map args from kwargs to instance-local variables
         map(lambda k, v: (k in self.__attrs__) and setattr(self, k, v),
                 kwargs.iterkeys(), kwargs.itervalues())
+
         # Map and wrap requests.api methods
         self._map_api_methods()
 
     def __repr__(self):
-        return '<requests-client at %s>' % (id(self))
+        return '<requests-client at 0x%x>' % (id(self))
 
     def _map_api_methods(self):
         """Reads each available method from requests.api and decorates
         them with a wrapper, which inserts any instance-local attributes
         (from __attrs__) that have been set, combining them with **kwargs.
         """
+
         def pass_args(func):
             def wrapper_func(*args, **kwargs):
                 inst_attrs = dict((k, v) for k, v in self.__dict__.iteritems()
@@ -41,6 +45,7 @@ class Session(object):
                 kwargs = dict(inst_attrs.items() + kwargs.items())
                 return func(*args, **kwargs)
             return wrapper_func
+
         # Map and decorate each function available in requests.api
         map(lambda fn: setattr(self, fn, pass_args(getattr(requests.api, fn))),
                 requests.api.__all__)