conversion between (OS native) paths and urls

Discussion in 'Python' started by Stefan Seefeld, Jul 5, 2004.

  1. hi there,

    I'm generating a set of html pages that refer to each other
    via relative URLs. However, during the generation of these
    files I only deal with paths (as generated by the os.path module).
    What is the suggested way to generate an url from a path,
    dealing with issues such as backslash-to-slash conversion on windows ?

    Thanks,
    Stefan
    Stefan Seefeld, Jul 5, 2004
    #1
    1. Advertising

  2. Stefan Seefeld

    Peter Otten Guest

    Stefan Seefeld wrote:

    > What is the suggested way to generate an url from a path,
    > dealing with issues such as backslash-to-slash conversion on windows ?


    >>> urllib.pathname2url("space jam/index.html")

    'space%20jam/index.html'
    >>>


    I'm confident that it will do the right thing on windows, too.

    Peter
    Peter Otten, Jul 5, 2004
    #2
    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. Kaidi
    Replies:
    5
    Views:
    454
    Andrew Thompson
    Jan 4, 2004
  2. Noah
    Replies:
    5
    Views:
    762
  3. David

    URLs and Paths and stuff

    David, Feb 11, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    801
    David
    Feb 12, 2007
  4. Nathan Sokalski

    Converting Relative URLs into Absolute URLs

    Nathan Sokalski, Aug 11, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    731
    Sriram Srivatsan
    Aug 12, 2008
  5. Adam Monsen

    JDBC URLs ...not really URLs?

    Adam Monsen, Feb 6, 2009, in forum: Java
    Replies:
    11
    Views:
    6,116
    Adam Monsen
    Feb 8, 2009
Loading...

Share This Page