usage of file separator

Discussion in 'Python' started by devnew@gmail.com, Dec 31, 2007.

  1. Guest

    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
     
    , Dec 31, 2007
    #1
    1. Advertising

  2. :
    > 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://gedankenkonstrukt.de/
    Jabber: -pobox.net
    GPG: 0xF534E231
     
    Thomas Wittek, Dec 31, 2007
    #2
    1. Advertising

  3. Guest


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


    thanx!
    dn
     
    , Jan 1, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. metfan
    Replies:
    2
    Views:
    4,863
    Robert Olofsson
    Oct 21, 2003
  2. Colin J. Williams

    Webchecker Usage - a problem with local usage

    Colin J. Williams, Feb 25, 2004, in forum: Python
    Replies:
    1
    Views:
    555
    Colin J. Williams
    Feb 26, 2004
  3. hvt
    Replies:
    0
    Views:
    1,220
  4. hvt
    Replies:
    0
    Views:
    1,497
  5. Krist
    Replies:
    8
    Views:
    6,591
    Arne Vajhøj
    Feb 10, 2010
Loading...

Share This Page