[Tutor] Considering translating bash script to Python to learn

spir denis.spir at free.fr
Tue May 12 11:11:38 CEST 2009


Le Tue, 12 May 2009 11:26:00 +0300,
Dotan Cohen <dotancohen at gmail.com> s'exprima ainsi:

> I am considering translating a homegrown bash script to Python to
> learn the language. The script grabs different specific pages of
> either a ODF or PDF file (I can use either as the input file, based on
> Python's abilities), combines it with an HTML file, rotates,
> rearranges, then sends the whole thing to the printer. However, I seem
> to depend on many bash-specific functions (os programs) and I cannot
> find Python equivalents. Here are some lines of the script, and the
> relevant questions:
> 
[...]
I think you should first keep these very pdf-specific tasks the way they are. Use the subprocess module to launch os commands. So that you can concentrate on translating the overall logic into python, which should not be too hard, probably.
> 
> Thanks for the help. I know that Python is not specifically designed
> to manipulate PDF files, but as the script is getting more complex and
> performs logic in other sections (not shown here) I would like to take
> advantage of other Python properties.
> 
Yes, I think it's a sensible thing to do. Python will provide a clearer process logic on a higher-level, and numerous side-advantages such as builtin or library toolsets.

Denis
------
la vita e estrany


More information about the Tutor mailing list