Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Alan Gauld
"michael scott" wrote say, how do I install a program to my computer, so that I can use it by its self without running it with python. Just to be clear, Python programs are interpreted by the Python interpreter. So while you can set things up such that you don't need to explicitly cakll

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread davidheiserca
I think I understand. One thing you can do is create a "myprogram.bat" file with an entry something like: python c:/myprogrampath/myprogram.py Put the "myprogram.bat" file in the root directory or any directory in the PATH. Then it will behave like an executable. In Linux, it would be "m

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Joel Goldstick
On Fri, May 20, 2011 at 2:10 PM, michael scott wrote: > Thank you for the reply, but thats not exactly what I mean. Perhaps I > should say, how do I install a program to my computer, so that I can use it > by its self without running it with python. No matter what directory I'm in > I can type moz

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Andre' Walker-Loud
Hi Michael, You have to do three (four) things. 1 - make a directory where you want your executables to live (after you have created them) on my machine, I copy everything to /usr/local/walkloud/bin/ which requires sudo, but you can put them anywhere in your $PATH 2 - in your .tcshrc or .csh

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread ian douglas
To expand further, some distributions of Linux set a 'bin' path under your home folder as part of your native PATH, even if it doesn't exist. So if your Linux username is, say, "mscott", see if "echo $PATH" already includes something like "/home/mscott/bin" in the path already. If so, simply c

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread michael scott
Thank you gentlemen so much, I believe I have all that I need to do what I wish. What is it about you... that intrigues me so?___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/list

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread michael scott
Thank you for the reply, but thats not exactly what I mean. Perhaps I should say, how do I install a program to my computer, so that I can use it by its self without running it with python. No matter what directory I'm in I can type mozilla in and it runs, no matter what directory I'm in if I t

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Noah Hall
On Fri, May 20, 2011 at 6:43 PM, michael scott wrote: > Okay, my title might be undescriptive, let me try to explain it better. I > want to take a script I've written and make it usable by typing its name in > the terminal. Perfect example is the python interpreter. You just type in > the word pyt

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread r...@schoenian-online.de
Hello Michael,   first you have to give your script an executable bit. Just type chmod +x your_script.py Furhtermore, your script has to be in a directory that is also part of your search path. Type in echo $PATH to see how your path is set. You can either link or copy your script to an approprate

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Edgar Almonte
hey ! i can answer that ! birst in the fist line of you script put something like this #!/usr/local/bin/python change the path for where you have python ( try using 'whereis python' ) sencond make the file executable add the +x attribute ( using chmod ) third put the script in some place and

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread Timo
On 20-05-11 19:43, michael scott wrote: Okay, my title might be undescriptive, let me try to explain it better. I want to take a script I've written and make it usable by typing its name in the terminal. Perfect example is the python interpreter. You just type in the word python to the terminal

Re: [Tutor] Making a script part of the terminal

2011-05-20 Thread James Reynolds
We just had a similar question yesterday. Just make sure Python is on your PATH. CD to the directory where your file is located and then you can just type "python myfile.py" where myfile is the name of your file. On Fri, May 20, 2011 at 1:43 PM, michael scott wrote: > Okay, my title might be und

[Tutor] Making a script part of the terminal

2011-05-20 Thread michael scott
Okay, my title might be undescriptive, let me try to explain it better. I want to take a script I've written and make it usable by typing its name in the terminal. Perfect example is the python interpreter. You just type in the word python to the terminal and then the interpreter runs. I know ot

Re: [Tutor] STRING PROC

2011-05-20 Thread Alan Gauld
wrote a.partition('<') ('', '<', 'NAME') Ooh! A new string method for me. I've never notioced partition before. Thanks for posting. Alan G. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pyth

Re: [Tutor] STRING PROC

2011-05-20 Thread spawgi
You can also try this >>> a = '>> a '>> a.partition('<') ('', '<', 'NAME') >>> splitstring = a.partition('<') >>> splitstring ('', '<', 'NAME') >>> splitstring[0] '' >>> splitstring[1] '<' >>> splitstring[2] 'NAME' I guess you can use this tuple. Hope this helps. Thanks and Regards, Sumod On F

Re: [Tutor] STRING PROC

2011-05-20 Thread Alan Gauld
"Spyros Charonis" wrote A quick string processing query. If I have an entry in a list such as ['>NAME\n'], is there a way to split it into two separate lines: NAME Yes if you know where the linebreak will be. s = ">NAME\n" twolines = [s[0],s[1:]] # list of two strings for line in tw

[Tutor] STRING PROC

2011-05-20 Thread Spyros Charonis
Hello List, A quick string processing query. If I have an entry in a list such as ['>NAME\n'], is there a way to split it into two separate lines: > NAME ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread Hilton Garcia Fernandes
Hi, Ganesh ! Adding to what Christian already stated, i'd like to tell you that an important use of this feature is the so-called modular testing, aka unit testing. I mean: that way you can provide functionality in your module to test it independently of any application it may be contained in. Un

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread Hilton Fernandes
Hi, Ganesh ! An important use of this feature is the so-called modular testing, aka unit testing. I mean: that way you can provide functionality in your module to test it independently of any application it may be contained in. Unit testing in general is easier and quicker to do than to test the

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread Christian Witts
On 2011/05/20 01:29 PM, Christian Witts wrote: On 2011/05/20 01:09 PM, Ganesh Kumar wrote: Hi Gurus, I am new python programming.. I see many programs if __name__ == '__main__': when I check __name__ always eq __main__. what purpose use these structure.. please guide me.. -Ganesh If you exe

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread Christian Witts
On 2011/05/20 01:09 PM, Ganesh Kumar wrote: Hi Gurus, I am new python programming.. I see many programs if __name__ == '__main__': when I check __name__ always eq __main__. what purpose use these structure.. please guide me.. -Ganesh If you execute the script directly ie. python script.py

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread spawgi
If the module is run as a program, then the __name__ is assigned the value __main__ . If the module is imported, then the value is not assigned. Please see here - http://stackoverflow.com/questions/419163/what-does-if-name-main-do

Re: [Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread Walter Prins
On 20 May 2011 12:09, Ganesh Kumar wrote: > Hi Gurus, > > I am new python programming.. I see many programs > if __name__ == '__main__': > when I check __name__ always eq __main__. > what purpose use these structure.. please guide me.. > > -Ganesh Here you go: http://lmgtfy.com/?q=What+is+the

[Tutor] What is `if __name__ == "__main__"` for?

2011-05-20 Thread Ganesh Kumar
Hi Gurus, I am new python programming.. I see many programs if __name__ == '__main__': when I check __name__ always eq __main__. what purpose use these structure.. please guide me.. -Ganesh -- Did I learn something today? If not, I wasted it. ___ Tut