> >(I know I'm being a bit silly about asking about what looks like a > >simple email typo, but computer programming bugs are all-too-often > >about typos. *grin* > > Sorry for the late response, I tried all of the the suggestions, > including correcting my typo of print sys[1:] and tried print > sys,argv[1:],
Hi Richard, Please, please copy and paste your code literally whenever you're talking about code. You have another email typo here, when you put a comma instead of a period in: sys,argv[1:] I know that's not what you meant, but I'm really trying to stress the idea that computers are not forgiving of typos. There are actually a large class of programming bugs that are simple typos. Make things easier for us: just copy and paste the code that you're talking about, and we'll be better able to replicate the situation that's on your side. I think there's been a lot of confusion on this thread, so let's backtrack again and make sure we're on the same page. I'll assume for the moment that your program looks like this: ###### import sys print sys.argv[1:] ###### > this does now work as long as I run 'python test.py fred joe' it returns > all the arguments. I expect to see: ### ['fred', 'joe'] ### because sys.argv should contain the list: ['test.py', 'fred', 'joe'] > If I try just test.py all I get is '[]'. Ok, this is also expected. If we give no command line arguments to our program, then we should get back an empty list from sys.argv[1:]. So at the moment, I actually have no clue what problem you're running into. *grin* What exactly are you getting stuck on? > Is there something wrong with my environmental variables in Windows XP, > I would like to be able to just use the file name rather than having to > type python each time. Wait. Ok, I think I understand the question now. I think you are trying to say that if you enter the command: ### C:\> test.py fred joe ### at your Windows command prompt, that Python responds with: ### [] ### Does this sound right? If so, then you are asking a question that's specific to Windows. The Windows command shell has a bug that has bitten folks before: Windows doesn't appear to correctly pass command line arguments to Python programs if we try to call the program directly. A workaround is to create a '.CMD' wrapper for your Python program. Add a file called 'test.cmd' in the same directory as your 'test.py' program with the following content: ### python test.cmd %* ### Once you have this file, try: ### C:\> test fred joe ### at your command line. You may find the discussion underneath: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/366355 useful, as the folks there further discuss this issue. Let's backtrack for a moment again: the reason we were not able to answer your question better was precisely because you were paraphrasing way too much: > ... as I run 'python test.py fred joe' it returns all the arguments. If > I try just test.py all I get is '[]'. If you had shown us exactly what you were entering into the command line, we would have caught the real cause of the problem much earlier. Ok, I'll stop ranting about this now. *grin* Best of wishes to you. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor