[Idle-dev] re: Bug in Python 1.6
Jake Baker
jbaker@ummelec.com
Wed, 04 Oct 2000 15:10:02 -0500
> In TreeWidget.py, assignment of '_icondir' using '__file__' is wrong,
> 'sys.argv[0]' works.
>
> '__file__' looks like 'C/C++' syntax.
>
> The way I found this problem by copying file to another directory and
> running it.
Not a bug. __file__ is a module attribute - if you didn't import the file =
as an module, then it doesn't exist in the namespace. __file__ evaluates =
to the full path of the python file which the module was loaded from.
> _icondir =3D os.path.join(os.path.dirname(sys.argv[0]), ICONDIR)
This doesn't work, at least under my system, because sys.argv[0] =3D=3D =
''. Your code would work as long as the current directory and the desired =
directory is the same.
(__file__ is not documented anywhere I can find.)