473,382 Members | 1,665 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,382 software developers and data experts.

Using command line args on Windows

k8
Hello-

I'm stuck on a Windows machine today and would love to fully play with
and test a simple python script. I want to be able to type "python
myscript myarg" somewhere. Is there anything out there to help me? My
main concern is playing with the myarg in the sys.argv list. I've been
mucking around with IDLE without much success.

Oct 5 '05 #1
7 1603
1) Start a command prompt window
(Start-Programs-Accessories-Command Prompt)
2) Change to directory where the python program is stored
(cd \<path-where-script-stored>)
3) Type python myscript.py myarg

-Larry Bates
k8 wrote:
Hello-

I'm stuck on a Windows machine today and would love to fully play with
and test a simple python script. I want to be able to type "python
myscript myarg" somewhere. Is there anything out there to help me? My
main concern is playing with the myarg in the sys.argv list. I've been
mucking around with IDLE without much success.

Oct 5 '05 #2
k8 wrote:
Hello-

I'm stuck on a Windows machine today and would love to fully play with
and test a simple python script. I want to be able to type "python
myscript myarg" somewhere. Is there anything out there to help me? My
main concern is playing with the myarg in the sys.argv list. I've been
mucking around with IDLE without much success.


Install cygwin. Don't confuse the cygwin python version with your
separately installed one, or don't install python via cygwin.

Regards,

Diez
Oct 5 '05 #3
k8
Thank you thank you thank you- The windows command line sol worked.

-k8

Oct 5 '05 #4
k8 wrote:
Thank you thank you thank you- The windows command line sol worked.


It sure does. But it sucks.. bad tab-completion, few tools, short
history, limited command-line-editing and so on. But if you want it the
hard way, it's your choice :)

Diez
Oct 6 '05 #5
"k8" wrote:
I'm stuck on a Windows machine today and would love to fully play with
and test a simple python script. I want to be able to type "python
myscript myarg" somewhere. Is there anything out there to help me?


footnote: if you'd prefer to type "myscript myarg" instead, you might want
to check out this tool:

http://effbot.org/zone/exemaker.htm

</F>

Oct 6 '05 #6
Fredrik Lundh wrote:
I'm stuck on a Windows machine today and would love to fully play
with and test a simple python script. I want to be able to type
"python myscript myarg" somewhere. Is there anything out there to
help me?


footnote: if you'd prefer to type "myscript myarg" instead, you might
want to check out this tool:

http://effbot.org/zone/exemaker.htm


or even just do:

SET PATHEXT=.py;%PATHEXT%

and then "myscript myarg" will work for all scripts on your path without
compiling (if you don't set PATHEXT then "myscript.py myarg" will still
work, and tab completion means you don't generally need to type the .py for
scripts in the current directory).
Oct 6 '05 #7
Duncan Booth <du**********@invalid.invalid> wrote:
Fredrik Lundh wrote:
footnote: if you'd prefer to type "myscript myarg" instead, you might
want to check out this tool:

http://effbot.org/zone/exemaker.htm


or even just do:

SET PATHEXT=.py;%PATHEXT%

and then "myscript myarg" will work for all scripts on your path without
compiling (if you don't set PATHEXT then "myscript.py myarg" will still
work, and tab completion means you don't generally need to type the .py for
scripts in the current directory).


The downside to this is that there is a bug in the NT/2K/XP command
interpreter which will prevent redirecting from stdin in that case. That
is:

C:\Tmp>type x.py
import sys
print sys.stdin.readline()

C:\Tmp>echo 123 | python x.py
123

C:\Tmp>echo 123 | x.py
The process tried to write to a nonexistent pipe.

C:\Tmp>python x.py < x.py
import sys

C:\Tmp>x.py < x.py

C:\Tmp>
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 9 '05 #8

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

Similar topics

6
by: Bharath Dhurjati | last post by:
Hello, I am looking for documentation that specifies the following behavior exhibited by java. The following (assuming MyClass.class is accessible and has a main()) java MyClass * yields...
6
by: Mark Miller | last post by:
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows...
5
by: Jarod | last post by:
Hey I have already written a program that has a user interface, but I would like to add some command line interface too. So if the user run it like: program.exe paramater1 The program do...
1
by: Peter Rilling | last post by:
I have an EXE that I would like to be able to run from either the command-line or as a windows service. Is there a way that I can tell which context the program is running in? Basically, if it...
4
by: Daniel Miller | last post by:
I have developed a simple text editing program using Windows Forms. I want to be able to right-click on a text file, choose "Open With" and select my program from the list to open the file, but I...
1
by: slonocode | last post by:
I have created a filter in Eudora email program that will notify a program when the criteria is met. For instance if the filter criteria is met it will send the following command: ...
1
by: lavu | last post by:
I currently have a C# windows Application . I would like this App to work through an command line interface also. I would like to specify command line params, which should start the app and process...
4
by: Milan | last post by:
How do you pass in arguments from the command line to a .Net windows app. Senario: vb.net application should be able to execute from command prompt by passing login and password and should be...
2
by: explode | last post by:
I made nova oledbdataadapter select update insert and delete command and connection veza. dataset is Studenti1data, I made it by the new data source wizard,and made datagridview and bindingsource...
1
by: ohaqqi | last post by:
Hi guys, I'm still working on my shell. I'm trying to implement a function typefile that will take a command line input as follows: > type <file1> This command will implement a catenation of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.