472,951 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,951 software developers and data experts.

sys.argv with quoted strings as option argument

Hi everyone,

I would like to send an option argument which is a quoted string with
whitespaces to a python program. For example:

$ ./myprogram.py --includedir="/usr/include /usr/local/include"
--libdir="/usr/lib /usr/local/lib"

However, sys.argv breaks the arguments whenever it encounter spaces,
like this:
['./myprogram.py', '--includedir=/usr/include', '/usr/local/include',
'--libdir=/usr/lib', '/usr/local/lib']

So I can't seem to use getopt or optik to process such cases. Is there a
good way where I can preserve such option arguments with whitespaces?

satya

--
Satya Nanda Vel Arjunan
Institute for Advanced Biosciences
Keio University
http://satya.host.sk/

Jul 18 '05 #1
1 2118
> However, sys.argv breaks the arguments whenever it encounter spaces,
like this:
['./myprogram.py', '--includedir=/usr/include', '/usr/local/include',
'--libdir=/usr/lib', '/usr/local/lib']

So I can't seem to use getopt or optik to process such cases. Is there a
good way where I can preserve such option arguments with whitespaces?


Under Linux, this works. So most probably this is a problem of your shell
(under windows?) Anther solution might be to specify every argument with
its own key like this:

../myprogram --include-dir=foo --include-dir=bar

Using getopt, you can build up the list on your own.

Diez
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Vinu | last post by:
Hai when i compile the cpp file(cmdargs.cpp) i attached the output below the program int main(int argc, wchar_t* argv) { std::wcout<<L"Name of the Program is "<<*argv<<std::endl;...
5
by: jab3 | last post by:
(again :)) Hello everyone. I'll ask this even at risk of being accused of not researching adequately. My question (before longer reasoning) is: How does declaring (or defining, whatever) a...
13
by: Vinu | last post by:
hai i have a problem i con't able to print the values of argv int main(int argc, wchar_t* argv) { return o; }
5
by: mwebel | last post by:
Hi, is is also a C question but the program im writing is in C++ and it applies as well so: i have a program in the "main(int argc, const char ** argv)" and i want to make a library. for...
5
by: jerry | last post by:
I need to modify the code of a command-line tool. The source code starts out like this: int main(int argc, char *argv) { int ch, A, B ; while ((ch = getopt(argc, argv, "AB")) != -1)...
56
by: subramanian100in | last post by:
The standard allows that we can copy strings onto arg, arg, etc. Why is it allowed ? What can be the maximum length of such a string that is copied ?
4
by: interec | last post by:
Hi Folks, I am writing a c++ program on redhat linux using main(int argc, wchar_t *argv). $LANG on console is set to "en_US.UTF-8". g++ compiler version is 3.4.6. Q1. what is the encoding of...
11
by: vicky | last post by:
hi all, please tell me with example, how the *argv point to the the no of strings.
2
by: Ben Bacarisse | last post by:
candide <candide@free.invalidwrites: argv can't be an array. It is a function parameter and arrays can't be passed to functions in C. There is indeed an array "out there" but all main can...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.