[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

usage of file separator

devnew@gmail.com

12/31/2007 3:56:00 PM

in my code i am iterating thru a list of filenames (like 'image1.jpg'
etc) and appending them to fully qualified directory names

for x in imagefilenames:
imgfile=folder+"/"+x
newimgfilenamelist.append(imgfile)

sothat finally i can get items like c:/mycode/image1.jpg etc from the
newimgfilenamelist

on windows this will work..but how do i make it work on other os?
Being a beginner i couldn't figure out how to solve this using
os.path can anyone help?

sorry if this is a silly qn
dn
2 Answers

Thomas Wittek

12/31/2007 4:59:00 PM

0

devnew@gmail.com:
> for x in imagefilenames:
> imgfile=folder+"/"+x
> newimgfilenamelist.append(imgfile)
>
> [..] how do i make it work on other os?

from os.path import join
#..
imgfile=join(folder, x)

--
Thomas Wittek
Web: http://gedankenkon...
Jabber: streawkceur@jabber.i-pobox.net
GPG: 0xF534E231

devnew@gmail.com

1/1/2008 5:49:00 AM

0


>
> from os.path import join
> #..
>     imgfile=join(folder, x)
>
> --
> Thomas Wittek
>

thanx!
dn