Project Home

callrdr.py

Abstract

Support code for rendering function calls to strings to be sent to Autograph. This module provides a function mkstreamtype() that you can call to create a new class that will render calls from its instances to a byte stream instead of calling anything by itself.

Table of Contents

Description

Support code for rendering function calls to strings to be sent to Autograph. This module provides a function mkstreamtype() that you can call to create a new class that will render calls from its instances to a byte stream instead of calling anything by itself.

For example, if you want to render calls to instances of a class 'Line' to stderr, you would to this:

Line = mkstreamtype('Line', sys.stderr)  # bind new class

ln = Line('line', (0.1, 1, 0.2), hintx="time", hinty="pnl")
ln.add(12.2, 13.1)
ln.remove('something')

which will result in the following output to stderr:

line = Line((0.10000000000000001, 1, 0.20000000000000001), hintx='time', hinty='pnl')
line.add(12.199999999999999, 13.1)
line.remove('something')

(Note that the representation of floats prevents us from precisely rendering out the original code.)

This can be useful for implementing a quick unidirectional protocol where the server evals the lines in an environment, instead of using something like XML-RPC.

Please Donate!

Important

This computer program or library is provided for free. I am aware that some of the programs that I provide for free allow people to get their work done faster or better, save them time and money. If you are using this program for benefit, especially if you are using it within a commercial environment and it saves you time or work, please consider making a donation by sending me a book from my Amazon Wishlist or by a direct donation to my company's PayPal account by clicking on the link below.

Download

Download program here.