def _safe_region(region=None, context=None):
    """Value to use when no region is specified."""
    ret = region or settings.get("region")
    context = context or identity
    if not ret:
        # Nothing specified; get the default from the identity object.
        if not context:
            _create_identity()
            context = identity
        ret = context.get_default_region()
    if not ret:
        # Use the first available region
        try:
            ret = regions[0]
        except __HOLE__:
            ret = ""
    return ret
dataset/ETHPy150Open rackspace/pyrax/pyrax/__init__.py/_safe_region