Anselm Kiefner added the comment:
I just stumbled over this same restriction and when I googled for "SyntaxError:
cannot assign to named expression", 0 actual results showed - an absolute
unicorn for a Python error.
> "Due to design constraints in the reference implemen
New submission from Anselm Kiefner:
Considering that
x = 3
f"{'hello' if x == 3 else 'goodbye'} world"
is a simple, elegant and powerful piece of code that works just as expected by
itself, I often find myself stumbling and wondering why
f"text {'\n
Anselm Kiefner added the comment:
Hey Eric, just a heads up.
In the latest jupyter notebook, this is valid code:
f"{eval('bool(0)\
and True\
')}"
which returns
'False'
I don't know how far you want to go, but if someone REALLY wants to use
backspace i
Anselm Kiefner added the comment:
Heh. I had a hunch it could be jupyter specific, but didn't test it. They had
problems with f-strings before, it seems they over-fixed those ..
Maybe you want to check their implementation and see if it's any good for a
general solution?
Oth
New submission from Anselm Kiefner:
from functools import singledispatch
from enum import Enum
IS = Enum("IS", "a, b")
@singledispatch
def foo(x):
print(foo.dispatch(x))
print("foo")
@foo.register(IS.a)
def bar(x):
print(foo.dispatch(x))
print