[Tutor] Using a calling program to change Python script arguments

Ray Jones crawlzone at gmail.com
Fri Aug 31 19:05:44 CEST 2012


As an aid to learning Python, I am currently in the process of
converting my Bash scripts into Python scripts. Through the years, as I
have accumulated a variety of sites, I have been maintaining a half
dozen or so Bash scripts that basically do the same thing: log me into a
streaming video site and record the stream.

So as I make this conversion, it's becoming obvious to me that as my
Python skill increases, I will be making changes to these scripts. But
that means maintaining all these scripts in parallel with each other.

I'm considering creating calling scripts (either Bash or another Python
script), all of which call a single Python capture script. Each calling
script would have its own info concerning IP, port, user name, password,
http or rtsp, time zone info, length of capture time, etc., and then
those scripts would pass their information to the single Python script,
greatly easing the maintenance issue.

But that's a ton of command line arguments to pass to the Python capture
script and have it parse. Is there another method for one Python script
to call/import/execute a Python script and integrate the name space so
that the variables in each of the calling scripts would be directly
usable by the Python module/child process/whatever without passing
arguments either via line arguments (yeccchhh!) or function calls
(considerably better)? Arguably, once the calling script passed the info
to the main script, it really wouldn't need to be there at all.

So how high is this pie-in-the-sky dream of mine?


Ray


More information about the Tutor mailing list