[Tutor] another ?-->if I created test.py how do I run test.pyin hello.py and also how do I run it again in hello.py?

Charles Gruschow, Jr. c.gruschow@prodigy.net
Wed, 23 Aug 2000 15:57:42 -0500


 I just thought that if you have a block of code that works on its own, you
could use that block in a different program if you wanted.  I wanted to know
how to originally call that block of code, and how to use it again in the
same program if you wanted to.  Like for example if you created an option
off a pull down menu that executes a python program, how do you get it so
that you can execute that option again.

BTW, thank you very much for your assistance so far.

Thanks,

Charles W. Gruschow, Jr.
c.gruschow@prodigy.net

p.s. I am learning quite a bit considering I only just got Python last
Friday.  :)




----- Original Message -----
From: Daniel Yoo <dyoo@hkn.EECS.Berkeley.EDU>
To: Charles Gruschow, Jr. <c.gruschow@prodigy.net>
Cc: <tutor@python.org>
Sent: Wednesday, August 23, 2000 2:31 PM
Subject: Re: [Tutor] another ?-->if I created test.py how do I run test.pyin
hello.py and also how do I run it again in hello.py?


> On Wed, 23 Aug 2000, Charles Gruschow, Jr. wrote:
>
> > another ?-->if I created test.py how do I run test.py in hello.py and
> > also how do I run it again in hello.py?
>
>
> I'm not quite sure if this is what you mean, but you can use
>
>     execfile("test.py")
>
> inside your hello.py file, and that'll execute test.py for you.  However,
> this is something uncommon to me.  Can you explain to us why you want to
> do this?
>