[Tkinter-discuss] Help with directories.

Jorge Constanzo lumberjack at educarchile.cl
Mon Jan 10 20:22:13 CET 2005


Hello:

My problem is this: I made a program that it reads from a file.
This file are in the same directory with the program. For getting this path, I've the
following code:

import os
path_file=os.path.dirname(__file__)

The command os.path.dirname(path_dir) returns the parent path of the path_dir and
__file__ returns the path of the current file (the file of the code). This code
worked very well in Windows (any version), but in Linux it doesn't work. I knew that
the command __file__ doesn't work in Linux (by means of print command :D) and that is
the reason of the problem.

My question is: somebody knows if it exists a command what does the same than command
__file__, but in Linux?

Thank you very much for your disposition
________________________________________________
Enviado por el servicio de correo de educarchile


More information about the Tkinter-discuss mailing list