On Sun, Jul 31, 2011 at 10:34, Peter Otten <__pete...@web.de> wrote:
>
> Richard D. Moores wrote:
>
> >> What happens if the path looks like
> >>
> >> r"C:relative\path\to\my\file.txt"
> >>
> >> or
> >>
> >> r"C:/mixed\slashes.txt"?
> >
> > Not quite sure what the intent of your question is, but al
Richard D. Moores wrote:
>> What happens if the path looks like
>>
>> r"C:relative\path\to\my\file.txt"
>>
>> or
>>
>> r"C:/mixed\slashes.txt"?
>
> Not quite sure what the intent of your question is, but all the paths
> I want to modify are full, with only back slashes.
If you invoke your fwd2bk
Nice!
That's what I've been expecting.
Thanks.
Your one string command is tiny and complete. And elegant.
Final desicion?
Or it could be something better and more professional?
So we have removed regexps and everything is fine now. Yes?
On Mon, 01 Aug 2011 02:37:09 +1000 Steven D'Aprano wrote
Sergey wrote:
Gotcha!
http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py
231-239 strings
## code ##
def convertPath(path):
# Convert windows, mac path to unix version.
separator = os.path.normpath("/")
if separator != "/":
path = re.sub(re.e
Haha. Works!
Happy help you.
Ask gurus about regexps. I know they have an opinion about its speed and
optimization. So they can try to criticise. But the problem is solved. It's
good.
On Sun, 31 Jul 2011 09:18:33 -0700 "Richard D. Moores"
wrote
>
> Nice!
>
> I went with
>
>
> import os.pat
On Sun, Jul 31, 2011 at 08:59, Sergey wrote:
> Gotcha!
> http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py
> 231-239 strings
>
> ## code ##
>
> def convertPath(path):
> # Convert windows, mac path to unix version.
> separator = os.path.normpath("/")
> if separat
Gotcha!
http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py
231-239 strings
## code ##
def convertPath(path):
# Convert windows, mac path to unix version.
separator = os.path.normpath("/")
if separator != "/":
path = re.sub(re.escape(separator)
On Sun, Jul 31, 2011 at 03:34, Peter Otten <__pete...@web.de> wrote:
> Sandip Bhattacharya wrote:
>
>> On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
>>> File "c:\P32Working\untitled-5.py", line 2
>>> return path.replace('\', '/')
>>> ^
>>> Synt
On Sun, Jul 31, 2011 at 03:34, Peter Otten <__pete...@web.de> wrote:
>
> Sandip Bhattacharya wrote:
>
> > On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
> >> File "c:\P32Working\untitled-5.py", line 2
> >> return path.replace('\', '/')
> >> ^
>
Maybe something useful could be find in urllib? It can open local files. And
UNIX slashes are equal to Web slashes.
http://docs.python.org/release/3.2.1/library/urllib.request.html#urllib.request.URLopener
--
class urllib.request.URLopener(proxies=None, **x509)
Base class for opening and readi
Sandip Bhattacharya wrote:
> On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
>> File "c:\P32Working\untitled-5.py", line 2
>>return path.replace('\', '/')
>>^
>> SyntaxError: EOL while scanning string literal
>> Process terminated with an exit
On Sat, Jul 30, 2011 at 23:32, Sandip Bhattacharya
wrote:
>
> On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
> > File "c:\P32Working\untitled-5.py", line 2
> > return path.replace('\', '/')
> > ^
> > SyntaxError: EOL while scanning string liter
Richard D. Moores wrote:
File "c:\P32Working\untitled-5.py", line 2
return path.replace('\', '/')
^
SyntaxError: EOL while scanning string literal
Others have already told you how to solve the immediate problem (namely,
escape the backslash), but I'd like to
Sandip Bhattacharya wrote:
Generally, converting slashes manually should be kept at a minimum. You
should be using library functions as much as possible. The experts here
can correct me here, but this is a roundabout way I would be doing this:
str.replace('\\', '/') is a perfectly fine library
On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
> File "c:\P32Working\untitled-5.py", line 2
>return path.replace('\', '/')
>^
> SyntaxError: EOL while scanning string literal
> Process terminated with an exit code of 1
The first backslash up
On Jul 31, 2011, at 1:28, "Richard D. Moores" wrote:
> 64-bit Vista
> Python 3.2.1
>
> I would like to write a function that would take a path such as
> 'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
> and return 'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' . I've
> tri
Try a double backslash
replace('\\','/')
On Jul 30, 2011 10:30 PM, "Richard D. Moores" wrote:
> 64-bit Vista
> Python 3.2.1
>
> I would like to write a function that would take a path such as
> 'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
> and return 'C:/Users/Dick/Desktop/Documents
Ruchard,
Try return path.replace('\\', '/'). That gave me the output desired by you.
I don't know the reason. But I guess it's because \ is used as escape
character. I am sure someone in the list will point out the accurate reason.
On Sun, Jul 31, 2011 at 10:58 AM, Richard D. Moores wrote:
> 64-
64-bit Vista
Python 3.2.1
I would like to write a function that would take a path such as
'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
and return 'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' . I've
tried this:
def test(path):
return path.replace('\', '/')
print(test(
19 matches
Mail list logo