Skip to content Skip to sidebar Skip to footer

Can Run Script Line By Line In Shell, But Full Script Returns Nothing

I'm using a script that extracts text from a PDF file. If I run my script one line at a time in the shell, it works fine (i.e. the extracted text is returned in the shell window),

Solution 1:

The Python shell echoes the results of expressions. In a script, you need to explicitly print your results:

print pageObj.extractText()

If Python where to behave differently, you could never write a script that remained silent.

Technically speaking, what the Python interactive shell does is use the repr() function, so every expression (unless it produces None) is written using print repr(<expression outcome>). print without repr() would use the str() function instead.

Post a Comment for "Can Run Script Line By Line In Shell, But Full Script Returns Nothing"