Import without executing module
python at bdurham.com
python at bdurham.com
Mon Feb 2 07:51:10 EST 2009
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?
Malcolm
----- Original message -----
From: "Stephen Hansen" <apt.shansen at gmail.com>
To: "Ray" <raykyoto at gmail.com>
Cc: python-list at python.org
Date: Sun, 1 Feb 2009 23:19:09 -0800
Subject: Re: Import without executing module
On Sun, Feb 1, 2009 at 11:05 PM, Ray <raykyoto at gmail.com> wrote:
> Basically, someone has created a python script and I would like to
> make use of his functions. I would prefer to not modify his file so
> what I would like to do is just write my script and import parts that
> are needed. i.e., I would like to separate my changes from his as
> best as I can. However, that other module has both functions (def's,
> which I would like to use) and top-level commands which I don't need
> and in fact, prints errors when I import it since it was meant to be
> run as a top-level module and not imported in. i.e., its expecting
> arguments to be supplied.
Unfortunately, that's not possible, I believe. All the top level
commands in a particular Python script are executed: that's how the
functions get created.
--S
--
http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list