473,395 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Access to sys.argv when python interpreter is invoked in some modes like 'python -c "command"'

The python tutorial says
"When the script name is given as '-' (meaning standard input),
sys.argv[0] is set to '-'. When -c command is used, sys.argv[0] is
set to '-c'. " but when we use a command say 'python -c "command"'
where can we access "sys.argv" (are there some commands where
"sys.argv" is accessed. I can run 'python -c "import sys sys.argv", I
get an error message

-Tiro

Aug 20 '06 #1
1 2560
po**************@gmail.com wrote:
The python tutorial says
"When the script name is given as '-' (meaning standard input),
sys.argv[0] is set to '-'. When -c command is used, sys.argv[0] is
set to '-c'. " but when we use a command say 'python -c "command"'
where can we access "sys.argv" (are there some commands where
"sys.argv" is accessed. I can run 'python -c "import sys sys.argv", I
get an error message

-Tiro
When you get an error message, and you ask a question concerning the
error message, *post* the error message.

But first, read it yourself. It will probably tell you what's wrong.
That's why it exists.

Meantime, what's your question?
BTW, "import sys sys.argv" is invalid python. When putting code
statements together on one line like this you must separate them with
";". I.e. "import sys; sys.argv". Note that this will still not do
what (I'm guessing) you want because this code is not being executed
interactively. It will simply "get" the value of sys.argv and then
throw it away. Try "import sys; print sys.argv", if you want to print
the value of sys.argv.

Happy coding,
~Simon

Aug 20 '06 #2

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

Similar topics

5
by: pekka niiranen | last post by:
Does anybody know Python recipe for changing the date of the directory or files in W2K to current date and time? In UNIX shell command "touch" does it. -pekka-
6
by: Clément Collin | last post by:
I working on a GIS project, with Access link which just need a little routine in VBA, but I haven't knowledges in VBA language. It's very simple, and it looks like that in a TPascal way : .......
6
by: Lars-Ove Andersson | last post by:
I have problem with the command "DLookup" in Access 2000. The command takes very long time to run. Have anybody any solution for this. //LOA
0
by: San Diego Guy | last post by:
Hi all! I have Datagrid. Within that datagrid I have a drop down list that I set up some values in (a "collection") I set up an edit command column on the datagrid and wrote simple code to get...
2
by: W3 | last post by:
Hi all, Just a quick one... Is there such a thing? Thanks, /Walter --
2
by: dstork | last post by:
Anyone know how to rename the "Exit Access" command at the bottom of the Office menu. I'd like to rename it to "Exit" as I had done in previous versions of Access. I know I can disable it with ...
3
by: =?iso-8859-1?q?KLEIN_St=E9phane?= | last post by:
Hi, for example, in http://svn.zope.org/zc.buildout/trunk/src/zc/buildout/ tests.py?rev=89831&view=auto test file, there is this doctests : def develop_verbose(): """ We should be able to...
0
by: Terry Reedy | last post by:
KLEIN Stéphane wrote: 'ls' is the unix abbreviation for the shell command 'list files (in a directory)'. The name is used above for a similar Python function. It presumably was imported...
2
by: chardish | last post by:
Hello, I'm trying to find out in a script where the location of the current python is. (I'm writing an installer script in python for a simple server application, so i'm going to do a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.