By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 935 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

How to send a file as an argument when running another file in Python

P: n/a
I have this file x.py and I need to execute it with y.met as an
argument. Unsure of syntax etc...

-Python newbie
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
se7en wrote:
I have this file x.py and I need to execute it with y.met as an
argument. Unsure of syntax etc...


import sys
print sys.argv

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2

P: n/a
On Thu, 05 Feb 2004 13:39:53 -0800, se7en wrote:
I have this file x.py and I need to execute it with y.met as an
argument. Unsure of syntax etc...

-Python newbie


Use:

import sys

filename = sys.argv[1]
print filename

Usage:

python x.py y.met

(sys.argv is a list where the first entry (i.e. sys.argv[0]) is
the name of your Python script and the other entries are the
command line arguments which you passed to your script.)

HTH / Nuff

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.