Re: How to split with "\" character, and licence copyleft mirror of ©

random832 at fastmail.us random832 at fastmail.us
Tue Sep 3 14:31:59 EDT 2013


On Tue, Sep 3, 2013, at 6:31, Tim Chase wrote:
> I'd contend that the two primary purposes of raw strings (this is
> starting to sound like a Spanish Inquisition sketch) are regexes and
> DOS/Win32 file path literals.  And I hit this trailing-backslash case
> all the time, as Vim's path-completion defaults to putting the
> trailing backslash at the end.  So I might be entering a literal like
> 
>   r"c:\win
> 
> and hit <tab> which expands to
> 
>   r"c:\Windows\
> 
> for which I then need to both remove the backslash and close the
> quote.  If Python's parser just blithely ignored terminal
> backslashes, I could just close the quote and get on with my day.

Of course, in 99% of situations where you can use a windows pathname in
Python, you are free to use it with a forward slash instead of a
backslash. The fact that you're using vim's file completion, which
automatically normalizes the path separator, is why you're running into
this issue when other people may not.

Maybe enabling the 'shellslash' option (which changes it to use forward
slash) will help you, though you should be aware this also affects the
expansion of the % variable, even in the :! command, which can cause
problems with certain usage patterns.



More information about the Python-list mailing list