<div>Hi all,</div><div><br></div><div>I am new to Python, i have installed python 2.5.4 and it is my requirement.</div><div><br></div><div>I need to retrieve the path of filename in python. </div><div><br></div><div>I have found some API's to get this:</div>
<div><br></div><div>from os.path import realpath</div><div>print realpath("NEWS.txt") # here NEWS.txt exists and it shows the path of the file as C:\Python25\WorkSpace\NEWS.txt</div><div>print realpath("abc.txt") # here abc.txt does not exist but still it shows C:\Python25\WorkSpace\abc.txt</div>
<div><br></div><div>can anybody tell the reason why????</div><div><br></div><div><br></div><div>Now took some safety measures:</div><div><br></div><div>found = lexists(realpath(filename))</div><div> if found == 0:</div>
<div> print "Not Found"</div><div> else:</div><div> print realpath(filename)</div><div><br></div><div>i have given the filename as "NEWS.txt" and "abc.txt" but i am always getting the output as "Not Found"</div>
<div><br></div><div><br></div><div>Can anyone please tell me where am i doing wrong????</div><div><br></div><div>also any suggestions to retrieve the filepath from a given filename is highly appreciated.</div><div><br></div>
<div>Thanks in advance.</div><div><br></div><div><br></div><div>Regards,</div><div>Sudhir</div>