def __init__(self,
                 environment='production',
                 api_base=None,
                 json=False,
                 _create_session=True):
        """Sets up Requests Session to be used for all connections to T1.

        :param environment: str to look up API Base to use. e.g. 'production'
        for https://api.mediamath.com/api/v2.0
        :param api_base: str API domain. should be the qualified domain name without
        trailing slash. e.g. "api.mediamath.com".
        :param _create_session: bool flag to create a Requests Session.
        Should only be used for initial T1 instantiation.
        """

        if api_base is None:
            try:
                Connection.__setattr__(self, 'api_base',
                                       API_BASES[environment])
            except __HOLE__:
                raise ClientError("Environment: {!r}, does not exist."
                                  .format(environment))
        else:
            Connection.__setattr__(self, 'api_base', api_base)

        Connection.__setattr__(self, 'json', json)

        if json:
            Connection.__setattr__(self, '_parser', JSONParser)
        else:
            Connection.__setattr__(self, '_parser', XMLParser)

        if _create_session:
            Connection.__setattr__(self, 'session', Session())
            self.session.headers['User-Agent'] = _generate_user_agent()
            if json:
                self.session.headers['Accept'] = ACCEPT_HEADERS['json']
dataset/ETHPy150Open MediaMath/t1-python/terminalone/connection.py/Connection.__init__