3 ms·
I can do this in Python with my `rwatch` module. >>> from datetime import datetime >>> x = lambda: f'{datetime.now()}' >>> x <function <lambda>
by jamesdutc 9y ago
I can do this in Python with my `rwatch` module.
>>> from datetime import datetime
>>> x = lambda: f'{datetime.now()}'
>>> x
<function <lambda> at 0x7f9f435e4510>
>>> x()
'2017-09-17 02:14:12.834957'
>>> from sys import setrwatch
>>> setrwatch({id(x): lambda f, o: o()})
>>> x # look, ma: no parens!
'2017-09-17 02:14:16.306198'
>>> x
'2017-09-17 02:14:17.734965'
- zwischenzug 9y agoI'm not sure how that is 'the same'?
- aidanhs 9y agoOne thing that may be non-obvious to people unfamiliar with Tcl is that it's syntactically a shell-like language, i.e. functions are invoked with a space-separated list of arguments and no parens. So `schro` on a line by itself executes the function and `[schro]` is equivalent to `$(schro)` in shell.
- tyingq 9y agoOnly when you're using the REPL. They call it "interactive mode". [ls], for example, will generate an error if you put that in a tcl script run non-interactively. Another common cause can be the difference between interactive and command modes for Tcl. When you start up a Tcl interpreter, get a prompt, and type in commands to Tcl, this is called interactive mode. In this mode, Tcl does a few extra things for you. For instance, if you type ls, and you have no proc called ls defined, Tcl will try to exec a command called ls. This sometimes misleads a new Tcl user into thinking that Tcl has ls defined." [1] [1] https://wiki.tcl.tk/1630 https://wiki.tcl.tk/1630