New to Python.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Scott F

    #16
    Re: New to Python.

    "Terry Reedy" <tjreedy@udel.e du> wrote in
    news:mailman.12 6.1079617542.74 2.python-list@python.org :
    [color=blue][color=green]
    >> You really want to use double backslashes (\\) here or use a raw
    >> string (r'...'). If not, this will eventually bite you.[/color]
    >
    > Or forward slashes (/), which avoids the whole problem.
    >[/color]

    for file() and similar, forward slashes are great, but try to spawn()
    something and a raw string works better.

    SDF

    Comment

    • Peter Hansen

      #17
      Slashes and Windows (was Re: New to Python.)

      Scott F wrote:[color=blue]
      > "Terry Reedy" <tjreedy@udel.e du> wrote in
      > news:mailman.12 6.1079617542.74 2.python-list@python.org :
      >[color=green][color=darkred]
      >>>You really want to use double backslashes (\\) here or use a raw
      >>>string (r'...'). If not, this will eventually bite you.[/color]
      >>
      >>Or forward slashes (/), which avoids the whole problem.[/color]
      >
      > for file() and similar, forward slashes are great, but try to spawn()
      > something and a raw string works better.[/color]

      The basic rule is that if you are passing the path through the command
      line (in effect, using os.system or spawn and friends), you need to use
      backslashes, but any other time forward slashes should be fine.

      Unfortunately, if you ever get into comparing path strings, and some
      have been made with forward slashes, while others used backslashes or
      were run through things like os.path.normpat h(), then you'll also get
      into trouble.

      -Peter

      Comment

      Working...