[ALUG] Python question about classes
Chris G
cl at isbd.net
Mon Jun 11 10:26:35 BST 2007
I'm trying to understand (and re-use) some Python code.
In general I find Python very easy to understand (one of the reasons I
like it) but I'm a bit unclear about one bit of code which is a
callback function, it is as follows:-
#
#
#
#
def cb_prepare(args):
request = args["request"]
data = request.getData()
data["statcatslinks"] = PyblStatcats(request)
It doesn't matter that it's a callback function (I can follow how/why
it gets called) and I can understand the first two lines. The first
line sets 'request' and the second gets the data dictionary from the
request object.
What I'm not clear about is the last line, PyblStatcats is a class.
As I understand it 'PyblStatcats(request)' creates an instance of
PyblStatcats and runs its __init__ method, so far so good. But what
does 'PyblStatcats(request)' return? It would appear to be a string
as it's used to set the value in the data dictionary. However I can't
find anywhere in the Python documentation that tells me about this
(implicit?) return value.
--
Chris Green
More information about the main
mailing list