Import without executing module

John Machin sjmachin at
Mon Feb 2 17:11:40 CET 2009

On Feb 2, 11:51 pm, pyt... at wrote:
> If the output is coming from a print command, couldn't the OP
> temporarily redirect STDIO to a file to prevent the output from being
> displayed?

He could, but that'd be a kludge on top of a stuff-up. He should put
the script-only statements inside
    if __name__ == '__main__':
and send the result back to the original author, who may in fact
appreciate being enlightened :-)


More information about the Python-list mailing list