/python_call

+ This calls a function in a python module you have loaded with
+ /python_load.
+ Since the code is already byte compiled, this is the fastest way to execute
+ python. And since the entire rest of the line is considered the argument,
+ you don't have to worry about quoting issues.
+
+

+ This will call mymodule.howdy() with the entire contents of the triggering
+ line as the argument whenever it matches a 'howdy' in a line. The real power
+ comes when using TinyFugue's powerful triggering and matching systems and
+ using a different method for each trigger type.
+
+

+ For a more complex example, see the included tf-lib/urlwatch.py which catches
+ all urls going by and writes a url launching page.
+
+

python()

+ This executes a single python expression. It must be an expression with a
+ return code, not a statement. For instance '1+1' is a expression that returns
+ 2, but 'print 1+1' is a statement and would be illegal. It will convert
+ string, float, integer, or boolean return values to equivalent TF values.
+
+

+ Example:
+ /test echo( python( strcat("'The current world is ", ${world_name}, ".'") ) )
+ The current world is (unnamed1).
+
+ Note that quoting is slightly tricky here - you have to quote once for TF's sake, then
+ once for python.
+
+

+ This invokes the python interpreter just as if you were entering commands at a
+ at a python cli. Each command must be standalone, but they can be statements
+ and there is a persistent environment, so you can do things like
+
+

+ Generally this is only useful in your .tfrc - or other script setup. It is slow since
+ the command has to be recompiled every time, and you don't get any return values.
+ You won't see any output unless there's an error or you explcitly invoke tf.out().
+
+

/python_load

+ This (re)imports a python module for you from your current PYTHONPATH, TFPATH,
+ and TFLIBDIR. Use this instead of just
+ '/python import mymodule'
+ because it will also force a reload of the module for you in case it has been
+ changed. Any functions in the module are now ready to use with
+ /python_call.
+
+

+ tf.world() - returns the name of the current world or empty string if none.
+
+

+ Arbitrary data from TF: Your program can retrieve any information it needs
+ from TinyFugue by doing the following (for example):
+ tf.eval( '/test "${world_name}"' )
+ will return a string containing the name of the current world or:
+ tf.eval( '/test columns()' )
+ will return an integer with the number of screen columns. Notice the
+ quoting is slightly depending on what we expect it to return.
+
+

+ See the included tf-lib/urlwatch.py and tf-lib/config.py for fairly complex
+ examples.
+
+

+ Calling back into TinyFugue: TF Python provides Python scripts with a 'tf'
+ module that has several methods - without these it's all fairly useless.
+ Please see /helptf module for info on this.

+
+

+ Speed: The python interpreter is (dynamically) embedded in TinyFugue to
+ reduce overhead and allow tighter coupling. When using
+ /python_load and
+ /python_call
+ all the code is byte compiled on load, so it's quite snappy.
+
+

+ Environment: The environment is persistent, so after '/python import glob'
+ subsequent commands will be able to reference module glob. More importantly
+ it means that after '/python_load mymodule' mymodule will have persistent
+ variables between /python_call invocations.
+
+

+ Arbitrary data from TF: Your program can retrieve any information it needs
+ from TinyFugue by using tf.eval.
+ Please see /helptf module for info on this.

+
+

+ stdout and stderr: by default, stdout is discarded (so you don't see the
+ output of every /python command) and stderr
+ is sent to tferr. You can make stdout active again with:
+ /python sys.stdout.output = tf.out
+ and shut it up again with:
+ /python sys.stdout.output = None
+ You can do the same with sys.stderr.output, but use tf.err instead.
+
+

+ See the included tf-lib/urlwatch.py and tf-lib/config.py for fairly complex
+ examples.
+
+