<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_environment(default=DEVELOPMENT, detectors=None, detectors_opts=None, use_envfiles=True):
 """Returns current environment type object. :param str|Environment|None default: Default environment type or alias. :param list[Detector] detectors: List of environment detectors to be used in chain. If not set, default builtin chain is used. :param dict detectors_opts: Detectors options dictionary. Where keys are detector names and values are keyword arguments dicts. :param bool use_envfiles: Whether to set environment variables (if not already set) using data from .env files. :rtype: Environment|None """

    detectors_opts = detectors_opts or {}

    if detectors is None:
        detectors = DETECTORS.keys()

    env = None

    for detector in detectors:
        opts = detectors_opts.get(detector, {})
        detector = get_detector(detector)

        detector = detector(**opts)
        env_name = detector.probe()

        if env_name:
            env = get_type(env_name)
            break

    if env is None and default is not None:
        env = get_type(default)

    if env is not None:
        env = env()  # type: Environment
        use_envfiles and env.update_from_envfiles()

    return env