[Tutor] If os.path.lexists() isn't working properly

Susana Iraiis Delgado Rodriguez susana.delgado_s at utzmg.edu.mx
Thu Nov 25 15:20:56 CET 2010


Hi Dave!

Thank you for your suggestion I haven't prevent the problems you're
describing, but I'm newbie in this stuff so, where should I repalce the
code?

Thank you again!
2010/11/24 Dave Angel <davea at ieee.org>

> On 01/-10/-28163 02:59 PM, Susana Iraiis Delgado Rodriguez wrote:
>
>> Hello Peter!
>>
>> I added the line you suggested me and found out that I was just searching
>> for the filenames without pointing to a specific directory, so Python took
>> its directory (Python26) as default. After that I need to add a '\' to
>> separate the path from the filename because it was reading them as a
>> single
>> string. But finally it worked nicely! here is the corrected script.
>>
>> <snip>
>>
>>  wksht.row(row).write(1, filename)
>>  n = os.path.splitext(filename)
>>  p = ruta+'\\'+n[0]+'.prj'
>>
>>
> Use os.path.join() to combine these nodes.  If you use an explicit
> backslash you can trigger two problems:  1) Your code won't be portable to
> other platforms  2) You could have trouble if one of the components already
> has a path separator.
>
>
> DaveA
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101125/33f56ae0/attachment.html>


More information about the Tutor mailing list