4 ms·
Bash rarely impresses me but this is a feature I love about it. I write Python normally, I really wish it had this.
by erdos4d 5y ago
Bash rarely impresses me but this is a feature I love about it. I write Python normally, I really wish it had this.
- frumiousirc 5y agohttps://www.python.org/dev/peps/pep-0572/ https://www.python.org/dev/peps/pep-0572/
- nijave 5y agotldr; `:=` assignment does this in Python 3.8+ while data := something_that_may_be_false(): # do something with data
- matvore 5y agoThis idea doesn't apply so cleanly in Python. The meaning of this: if x=$(foo); then ... fi is that the stdout of running `foo` replaces the contents of $x and the `if` evaluates the exit code of `foo`. Python doesn't see stdout as some kind of first-class language construct. I also don't think this could ever work on Windows if you expect `foo` to be a simple function that has access to the interpreter state.