View Single Post
Join Date: Jul 2008
Posts: 1,054
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 265
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Help with finding out if a program exists in os path entries

 
0
  #2
Nov 26th, 2008
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:
  1. #!/usr/bin/python
  2. import #whatever needs imported
  3.  
  4. def # Define some functions
  5.  
  6. def main():
  7. # Do anything that needs done here
  8. # Call functions, etc...
  9.  
  10. if __name__ == '__main__':
  11. main()
Last edited by jlm699; Nov 26th, 2008 at 3:32 pm.
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote