[Scribus] Scripter using Python calendar modules - prcal, prmonth

Craig Ringer craig
Mon Aug 21 02:45:07 CEST 2006


Craig Ringer wrote:

> You need to find a function in the calendar module that _returns_ the 
> formatted calendar rather than printing it.

import calendar
help(calendar)

reveals that that function is calendar.month(). Python's built-in help 
is great (and works fine in the script console) - you can call help() on 
any Python object to display its docstring, eg:

help(calendar)
help(calendar.month)
help("fred")
help(4)
help(int)

The type() function is also very useful.

I strongly suggest you become familiar with the difference between 
returning a value and printing it to the console. It's easier to tell 
which is which on Python's built-in interactive console - you can get it 
by running `python' on the command line - but you can't use Scribus's 
Python APIs from there. In the Scribus console, if you're unsure, run 
just the command you're wondering about and assign its return value to a 
variable. If it prints something, you know it's actually writing to 
stdout; if instead nothing is printed and the variable takes on a value, 
you know it's returning the data.

--
Craig Ringer



More information about the scribus mailing list