![]() |
| ||
| Help with finding out if a program exists in os path entries Hey hey! I'm trying to write a script that finds out if a given program name exists in the OS environments PATH variable (cross plathform). Thing is, I get a NameError, it's probably a simple error, but I've struggling with it the last hour. Any help would be appreciated #!/usr/bin/env python |
| ||
| Re: Help with finding out if a program exists in os path entries You're calling the function findprogram before defining it.... if you simply rearrange your code so that the def findprogram(program):block is first, you'll solve the problem. You'll then find that you forgot to import sys And then you'll find that you're trying to use some variable called program_path when instead you might have wanted fullpath A good way to avoid this is to not ever let your code hang out in the ether like that... commonplace is to place your code all into functions, and have a main() function to call them... Here's a pretty commonly used method: #!/usr/bin/python |
| ||
| Re: Help with finding out if a program exists in os path entries Crap, I see that now. I can't belive I'd forgotton how C-like python was. Is there any way you can define prototypes in python like C? |
| All times are GMT -4. The time now is 12:31 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC