[Tutor] PYTHONPATH (Mac OS X)
Stayvoid
stayvoid at gmail.com
Fri Dec 30 14:11:17 CET 2011
>You don't have any option.
>You either type in the full path or you get the user to tell you
>in some way - either with a prompt or via an input argument.
OK, now I get it.
How can I tell this to the end-user?
Should I write a README file or what?
I've tried to run lengthcounter_lutz from the file's folder and this worked out.
cd /Users/Username/Python_modules/
python /Users/Username/Python_modules/lengthcounter_lutz.py
('Lines:', 12, 'Chars:', 285)
But I can't understand what's wrong with the second one:
def countLines(name):
file = open(name.__file__)
return len(file.readlines())
def countChars(name):
return len(open(name.__file__).read())
def test(name):
return "Lines:", countLines(name), "Chars:", countChars(name)
if __name__ == '__main__':
import lengthcounter
print test(lengthcounter)
>>> import lengthcounter
>>> lengthcounter.test(lengthcounter)
('Lines:', 5, 'Chars:', 885)
That PYTHONPATH variable has no connection with the mess above. When
should I use it?
Thanks for your help.
More information about the Tutor
mailing list