On Thursday, November 20, 2003, at 12:21 AM, Ian Bicking wrote:
On Nov 19, 2003, at 8:02 PM, david wrote:Ian,
I have grabbed the standalone webkit from the webware sandbox.
I have edited FileLocations.ini and changed GlobalFileLocationConf in Server.py
When in the test directory I type ../../Server --EnableHTTP=yes --HTTPPort=8080 and get back
Traceback (most recent call last): File "../../Server.py", line 159, in ? setupPath() File "../../Server.py", line 9, in setupPath myDir = os.path.dirname(os.path.abspath(__file__)) NameError: global name '__file__' is not defined
I have tried with and without the changes to Server suggested by Ricardo.
I don't quite get that. I don't know why __file__ sometimes exists, and sometimes doesn't. It annoys me, because I can't always reproduce it. Maybe it's based on the Python version.
Anyway, I just checked in something that maybe will help -- if __file__ is missing it uses sys.argv[0].
This __file__ thing always annoyed me, too, but I think I finally got it figured out. If I have a file 'mytest.py' like so:
# simple mytest.py file
def test():
return __file__
if __name__ == '__main__':
print test()...and I try "python mytest.py" at a command promp, I get this:
Traceback (most recent call last):
File "mytest.py", line 5, in ?
print test()
File "mytest.py", line 2, in test
return __file__
NameError: global name '__file__' is not definedThough, I get the __file__ variable if I import the module:
>>> import mytest >>> mytest.test() 'mytest.pyc' >>>
I think that the __file__ variable exists only for modules. If you're in __main__, then it won't be there. Sometimes, I've done the following but I think it's probably a bad idea:
# simple mytest2.py file
def test():
import mytest2
return mytest2.__file__
if __name__ == '__main__':
print test()--Tracy
------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
