[Python-Dev] File Path retrieving problem (original) (raw)

Sudhir Kakumanu music24by7 at gmail.com
Wed Feb 25 16:12:43 CET 2009


Hi all, I am new to Python, i have installed python 2.5.4 and it is my requirement.

I need to retrieve the path of filename in python.

I have found some API's to get this:

from os.path import realpath print realpath("NEWS.txt") # here NEWS.txt exists and it shows the path of the file as C:\Python25\WorkSpace\NEWS.txt print realpath("abc.txt") # here abc.txt does not exist but still it shows C:\Python25\WorkSpace\abc.txt

can anybody tell the reason why????

Now took some safety measures:

found = lexists(realpath(filename)) if found == 0: print "Not Found" else: print realpath(filename)

i have given the filename as "NEWS.txt" and "abc.txt" but i am always getting the output as "Not Found"

Can anyone please tell me where am i doing wrong????

also any suggestions to retrieve the filepath from a given filename is highly appreciated.

Thanks in advance.

Regards, Sudhir -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20090225/9a104741/attachment.htm>



More information about the Python-Dev mailing list