Tutorial - section 8.5 -- User Defined Execptions?
Erik Max Francis
max at alcyone.com
Thu Apr 17 19:58:44 CEST 2003
Bengt Richter wrote:
> What other use is there (outside of strings and comments)?
> Have we purposely been set up for gaucheries?
In shell-like languages, the backquotes are used to mean "Execute what's
in between the backquotes as a shell command, and then substitute the
(stdout) output of that command and continue, e.g.:
max at oxygen:~% echo The date is: `date`
The date is: Thu Apr 17 10:54:03 PDT 2003
In modern shells, the form $(...) is preferred to `...`, since the
former can be nested, whereas the latter cannot.
As for Python's use of the backquotes, I presume it's some historical
issue. I don't know what Guido would say about its use now, but there
seems pretty near total consensus that repr(x) looks a lot better (and
clearer) than `x`.
I do occasionally use `x`, but only when inserting debug statements
since they're set off so obviously. "Oh, I see backquotes, that
shouldn't stay in there in production code."
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Freedom is a road seldom travelled by the multitudes
\__/ Public Enemy
The laws list / http://www.alcyone.com/max/physics/laws/
Laws, rules, principles, effects, paradoxes, etc. in physics.
More information about the Python-list