def run_in_env(env):
def decorator(func):
def wrapper(*args, **kwargs):
current_env = "production" # Simulated environment
if current_env == env:
return func(*args, **kwargs)
else:
print(f"Function can only run in the '{env}' environment.")
return wrapper
return decorator
@run_in_env("development")
def debug_mode():
print("Debugging application...")
debug_mode() # Will not execute unless the environment is "development"