<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def arctic_setting(setting_name, valid_options=None):
 """ Tries to get a setting from the django settings, if not available defaults to the one defined in defaults.py """

    try:
        value = getattr(settings, setting_name)
        if valid_options and value not in valid_options:
            error_message = "Invalid value for {}, must be one of: {}".format(
                setting_name, str(valid_options)
            )
            raise ImproperlyConfigured(error_message)
    except AttributeError:
        pass
    return getattr(settings, setting_name, getattr(defaults, setting_name))