I have a function I want to take different form depending on the mode. Should I enclose the definition within the if statement or should I put the if inside the definition?

```
# Case 1
if mode == 1:
    def f(x):
        return x + 5
else:
    def f(x):
        return x - 5

# Case 2
def f(x):
    if mode == 1:
        return x + 5
    else:
        return x - 5

```

I have done both in the past and my static code analysis tools don't seem to complain. So I was wondering whether there is a Pythonic recommendation? 

EDIT: From the comments so far, both cases seem acceptable. It depends on the use case. If mode is intended to be constant, Case 1 is preferred. If not, then Case 2.

EDIT2: This question actually arose as I was writing a function. It takes in mode as an input and depending on the mode perform similar operations except it uses a different subfunction defined solely within the function for those operations. As the subfunction stays constant during the running of the function, Case 1 would seem to be more appropriate.

EDIT3: Correction: In the past, I believed it was PyLint that was not comfortable with Case 1. These days, I use PyCharm and that doesn't seem to flag any issues with Case 1.