PEP8 does not indicate whether to return a variable depending on the function.
However, he says you should be consistent:
return. return , . - , , , return None, return ( ).
# Yes
def myfunction(a: int, b: int) -> int:
if a % 2 == 0:
return int(a ** b)
else:
return 0
# No
def my_bad_function(a: int, b: int) -> int:
if a % 2 == 0:
return int(a ** b)
# Implicitly returns None when the above if statement evaluates False
( PEP8), .
, . None.
, , , , , int, int.bit_length()
, :
for n in range(1, 10):
nlen = my_bad_function(n * 5, n).bit_length()