How to call .py file into another .py file

hi guy,

I am facing some problem. I want to execute a (.py) extension file into
another (.py) extension file. i am tired of searching on websites but
didn’t
get any satisfactory results. Is it possible or is there any other way
of
doing this. can anyone help please.

Ali

On Tue, Jan 26, 2010 at 02:51:36PM -0500, Muhammad Ali K. wrote:

hi guy,

I am facing some problem. I want to execute a (.py) extension file into
another (.py) extension file. i am tired of searching on websites but didn’t
get any satisfactory results. Is it possible or is there any other way of
doing this. can anyone help please.

Ali

I suggest starting with the Python Tutorial:

http://docs.python.org/tutorial

Or in pdf:

http://docs.python.org/download.html

Eric

Hello,

That’s not a good python textbook, it is more like a quick start guide.
I
would suggest him
“Learning python 4th edition” from Mark Lutz.

http://oreilly.com/catalog/9780596158071

yours faithfull
Josef V.

2010/1/26 Eric B. [email protected]

Thanks for your suggestions guys. But i think i didn’t convey myself
properly. Right now i want to fetch out the gain at some frequency using
(usrp_wfm_rcv.py) in a loop in which i can change my frequency in every
iteration. is there any way i can get it.

Thanks

Ali

On Tue, Jan 26, 2010 at 3:23 PM, Josef V.

Hello,

That’s not a good python textbook, it is more like a quick start guide.
I
would suggest him
“Learning python 4th edition” from Mark Lutz.

http://oreilly.com/catalog/9780596158071

yours faithful
Josef V.

Yes, there is. Try the “subprocess.Popen” command in python (
http://docs.python.org/library/subprocess.html). The one thing in this
code
that you will need to modify slightly is in the calls to set up the
pipes,
you need to to use “subprocess.PIPE” instead of simply “PIPE”.

At this point, you could use the pipe to communicate to the other
process
both ways. The easiest way I have found for this is with the
“os.read(…)”
and “os.write(…)” commands. One thing about the os.write and os.read
commands is that for the first parameter you will need the file
descriptor
number, not the file descriptor.

To get this, lets say you assign the subprocess to “p”; in order to get
the
file number in order to talk to the child process, you would type in
“p.stdin.fileno()” to write to the process, or “p.stdout.fileno()” to
read
from the process. Another simple way to write to a process at startup
is to
pass it arguments.

Here is some source code that shows how to do this (
http://code.google.com/p/softwaredefinedradio/source/browse/trunk/src/FFT/get_fft.py).
On line 40, this shows how to dynamically assign arguments to a child
process with the subprocess.Popen command, as well as how to read in the
arguments very simply on lines 7, 15, 23, 31 with the use of the argv
array
(mind you that argv[0] is the process name). This example also shows
how to
use the os.write on lines 42 and 43.

Thanks,
Michael B.

On Tue, Jan 26, 2010 at 7:04 PM, Muhammad Ali K. [email protected]
wrote:

[email protected]> wrote:

Josef V.

another (.py) extension file. i am tired of searching on websites but

[email protected]

-Michael B.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs