[IPython-user] More Windows questions part 2 - \/ characters revisited

Ville Vainio vivainio at gmail.com
Wed Jun 22 02:39:35 CDT 2005

On 6/21/05, Fernando Perez <Fernando.Perez at colorado.edu> wrote:

> >    a. The cd command, being a Magic command, seems to always work, as
> >       long as I use the default directory character which is /.
> >       Autocomplete adds /, but converts it correctly.  'cd -', 'cd -b
> >       name', and 'cd -n' formats all work.

There's no need for conversion, / is a valid path separator in win32.

> >    b. It looks like everywhere that saves path names, the correct
> >       os.sep (\) is being used.  (dhist, bookmark -l, and dirs).

Yeah, they use os.path.abspath directly without converting to /. For
the sake of uniformity they should perhaps do the \ -> / conversion.

> >    c. pushd: only works with /
> >    d. popd: *** does not work.  For some reason it seems to be removing
> >       ALL the \ characters before attempt to change directories.  Like
> >       I mentioned, cd -n, and cd -b name all correctly retrieve and
> >       handle this.

Should be fixed, then. I don't use pushd/popd so I haven't noticed.

> >    e. any other (non-cd or pushd) commands, if you change the first
> >       delimiter to be \ instead of /, then the autocomplete will work.

Yes, many dos commands think that / starts a "switch".

> >    g. I think that if the autocomplete would ALWAYS use os.sep,
> >       instead of / (and modify the cd and pushd commands to use os.sep
> >       also), then the frustration would be gone.

\ is an escape character in python, so there would be lots of new
sources of frustration. All the \'s would have to be doubled, for one.
And how would we escape stuff, then? Also, many unix programs that ppl
may be running on windows want / separators, so ppl would want to make
the separator configurable - I would still want to use /, for example.

> If win32 users can modify that code to fix the remaining annoyances, and
> test things out by themselves, I'll be more than happy to incorporate
> the changes.  I trust Ville's knowledge of ipython's internals and of
> win32, so if you want to work with him (and if he's interested, of
> course), any patches he vets are OK with me.  If Ville can't work on
> this, I can always put out a test release so other win32 users can test
> things before the code becomes official.

Well, the thing is I don't even WANT to introduce \ as path separator
in win32, even if it corrected some problems people may be having.
Win32 is evil, \ as pathsep is evil and I prefer the thing to work in
an unixy way because it's much more natural in python, / being just a
plain old character among others. Some programs expect \ - it could be
argued that such programs are broken, not ipython - but as said
previously it can be circumvented by doing the \\tmp/a/b/c.txt, so
it's not a big deal.

> Note that I think, re. 2g, that Ville specifically did NOT use os.sep
> always for reasons I forget.  But I'm almost sure it wasn't accidental.

Yep, there are also explicit conversions from \ to /. It's a feature,
not a bug. cmd.exe is not python so there is no reason to escape
stuff, hence the "natural" functionality of \.

More information about the IPython-user mailing list