I would like to do the equivalent of the following in Python:
x = {
// code here
return some_value
}
Is there any way to do this in Python without having to define a whole new function?
i.e. This
x = :
# code here
return some_value
And not this
def func():
# code here
return some_value
x = func()
EDIT: I know that this example was 1 line and I can use a lambda for this specific example, however, I'm wanting to use this for code that requires multiple lines, which is why I cannot use a lambda. I will edit the code to include more than one line.