943,902 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 1110
  • Python RSS
Aug 22nd, 2009
0

What does the sys module do in python?

Expand Post »
What does the sys module do in python?
and what is sys.argv?
Similar Threads
Reputation Points: 16
Solved Threads: 2
Posting Whiz in Training
mahela007 is offline Offline
214 posts
since Feb 2009
Aug 23rd, 2009
0

Re: What does the sys module do in python?

Reputation Points: 930
Solved Threads: 668
Posting Maven
Gribouillis is offline Offline
2,655 posts
since Jul 2008
Aug 23rd, 2009
0

Re: What does the sys module do in python?

That's exactly where I checked. I don't understand what the documentation says..
More specifically I don't understand this
"sys.argv¶

The list of command line arguments passed to a Python script. argv[0] is the script name (it is operating system dependent whether this is a full pathname or not). If the command was executed using the -c command line option to the interpreter, argv[0] is set to the string '-c'. If no script name was passed to the Python interpreter, argv[0] is the empty string."
Reputation Points: 16
Solved Threads: 2
Posting Whiz in Training
mahela007 is offline Offline
214 posts
since Feb 2009
Aug 23rd, 2009
0

Re: What does the sys module do in python?

Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Aug 23rd, 2009
2

Re: What does the sys module do in python?

Maybe a little example will help ...
python Syntax (Toggle Plain Text)
  1. import sys
  2.  
  3. args = sys.argv
  4.  
  5. print(args)
  6. print( "Source file: %s" % args[0] )
  7. # use any of these arguments in your code
  8. print( "Argument one: %s" % args[1] )
  9. print( "Argument two: %s" % args[2] )
  10.  
  11.  
  12. """
  13. my output after saving this code as sysargs1.py and
  14. entering a few arguments on the command line -->
  15. ['D:/Python25/Bull/sysargs1.py', 'myarg1', 'myarg2']
  16. Source file: D:/Python25/Bull/sysargs1.py
  17. Argument one: myarg1
  18. Argument two: myarg2
  19. """
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Aug 24th, 2009
0

Re: What does the sys module do in python?

So for the last two to have values, is it compulsory for the program to be run via command line?
Reputation Points: 16
Solved Threads: 2
Posting Whiz in Training
mahela007 is offline Offline
214 posts
since Feb 2009
Aug 24th, 2009
0

Re: What does the sys module do in python?

You can run it with module subprocess as well
python Syntax (Toggle Plain Text)
  1. import subprocess
  2. child = subprocess.Popen("sysargs1.py myarg1 myrag2", shell=True)
Reputation Points: 930
Solved Threads: 668
Posting Maven
Gribouillis is offline Offline
2,655 posts
since Jul 2008
Aug 25th, 2009
0

Re: What does the sys module do in python?

What does that module do?
Reputation Points: 16
Solved Threads: 2
Posting Whiz in Training
mahela007 is offline Offline
214 posts
since Feb 2009
Aug 25th, 2009
1

Re: What does the sys module do in python?

It allows your program to launch other programs and communicate with them.
Reputation Points: 930
Solved Threads: 668
Posting Maven
Gribouillis is offline Offline
2,655 posts
since Jul 2008
Aug 25th, 2009
0

Re: What does the sys module do in python?

thanks
Reputation Points: 16
Solved Threads: 2
Posting Whiz in Training
mahela007 is offline Offline
214 posts
since Feb 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Download function
Next Thread in Python Forum Timeline: stcuk with dictionary





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC