Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38203 > unrolled thread

Re: Best Practice Question

Started bypython.list@tim.thechases.com
First post2013-02-05 09:17 -0600
Last post2013-02-05 08:40 -0800
Articles 5 — 4 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Best Practice Question python.list@tim.thechases.com - 2013-02-05 09:17 -0600
    Re: Best Practice Question Anthony Correia <akcorreia@gmail.com> - 2013-02-05 08:40 -0800
      Re: Best Practice Question Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-05 11:53 -0500
      Re: Best Practice Question Dave Angel <d@davea.name> - 2013-02-05 13:10 -0500
    Re: Best Practice Question Anthony Correia <akcorreia@gmail.com> - 2013-02-05 08:40 -0800

#38203 — Re: Best Practice Question

Frompython.list@tim.thechases.com
Date2013-02-05 09:17 -0600
SubjectRe: Best Practice Question
Message-ID<mailman.1370.1360081284.2939.python-list@python.org>
On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote:
> By the way, did someone ever notice that r'\' fails ? I'm sure
> there's a reason for that... (python 2.5) Anyone knows ?
> 
> r'\'
> SyntaxError: EOL while scanning single-quoted string

I hit this all the time with Vim's path-completion (":help
i_CTRL-X_CTRL-F") on Win32 which puts a trailing "\" on
directory-names.  I just need to remember to remove it, a task made
easier because the syntax highlighting correctly shows how Python
interprets it (i.e., the string is still continued).

-tkc

[toc] | [next] | [standalone]


#38204

FromAnthony Correia <akcorreia@gmail.com>
Date2013-02-05 08:40 -0800
Message-ID<b04a6aad-1730-403d-88d4-716be2033296@googlegroups.com>
In reply to#38203
On Tuesday, February 5, 2013 10:17:54 AM UTC-5, pytho...@tim.thechases.com wrote:
> On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote:
> 
> > By the way, did someone ever notice that r'\' fails ? I'm sure
> 
> > there's a reason for that... (python 2.5) Anyone knows ?
> 
> > 
> 
> > r'\'
> 
> > SyntaxError: EOL while scanning single-quoted string
> 
> 
> 
> I hit this all the time with Vim's path-completion (":help
> 
> i_CTRL-X_CTRL-F") on Win32 which puts a trailing "\" on
> 
> directory-names.  I just need to remember to remove it, a task made
> 
> easier because the syntax highlighting correctly shows how Python
> 
> interprets it (i.e., the string is still continued).
> 
> 
> 
> -tkc

Sorry about that I hit the touchpad on my laptop by mistake.  Beside the using  single '\' vs a double '\\' does that look ok?

[toc] | [prev] | [next] | [standalone]


#38206

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-02-05 11:53 -0500
Message-ID<mailman.1373.1360083208.2939.python-list@python.org>
In reply to#38204

[Multipart message — attachments visible in raw view] — view raw

On Tue, Feb 5, 2013 at 11:40 AM, Anthony Correia <akcorreia@gmail.com>wrote:

> On Tuesday, February 5, 2013 10:17:54 AM UTC-5, pytho...@tim.thechases.comwrote:
> > On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote:
> >
> > > By the way, did someone ever notice that r'\' fails ? I'm sure
> >
> > > there's a reason for that... (python 2.5) Anyone knows ?
> >
> > >
> >
> > > r'\'
> >
> > > SyntaxError: EOL while scanning single-quoted string
> >
> >
> >
> > I hit this all the time with Vim's path-completion (":help
> >
> > i_CTRL-X_CTRL-F") on Win32 which puts a trailing "\" on
> >
> > directory-names.  I just need to remember to remove it, a task made
> >
> > easier because the syntax highlighting correctly shows how Python
> >
> > interprets it (i.e., the string is still continued).
> >
> >
> >
> > -tkc
>
> Sorry about that I hit the touchpad on my laptop by mistake.  Beside the
> using  single '\' vs a double '\\' does that look ok?
> --
> http://mail.python.org/mailman/listinfo/python-list
>

according to the docs for os.path.join, you don't need the backslash stuff
at all.  Python knows the correct separator for your os and inserts it
accordingling:
I'm on linux:

>>> import os
>>> p = os.path.join('bob', 'bill')
>>> p
'bob/bill'
>>>


-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#38210

FromDave Angel <d@davea.name>
Date2013-02-05 13:10 -0500
Message-ID<mailman.1375.1360087880.2939.python-list@python.org>
In reply to#38204
On 02/05/2013 11:53 AM, Joel Goldstick wrote:
> On Tue, Feb 5, 2013 at 11:40 AM, Anthony Correia <akcorreia@gmail.com>wrote:
>
>> On Tuesday, February 5, 2013 10:17:54 AM UTC-5, pytho...@tim.thechases.comwrote:
>>> On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote:
>>>
>>>> By the way, did someone ever notice that r'\' fails ? I'm sure
>>>
>>>> there's a reason for that... (python 2.5) Anyone knows ?
>>>
>>>>
>>>
>>>> r'\'
>>>
>>>> SyntaxError: EOL while scanning single-quoted string
>>>
>>>
>>>
>>> I hit this all the time with Vim's path-completion (":help
>>>
>>> i_CTRL-X_CTRL-F") on Win32 which puts a trailing "\" on
>>>
>>> directory-names.  I just need to remember to remove it, a task made
>>>
>>> easier because the syntax highlighting correctly shows how Python
>>>
>>> interprets it (i.e., the string is still continued).
>>>
>>>
>>>
>>> -tkc
>>
>> Sorry about that I hit the touchpad on my laptop by mistake.  Beside the
>> using  single '\' vs a double '\\' does that look ok?
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>
> according to the docs for os.path.join, you don't need the backslash stuff
> at all.  Python knows the correct separator for your os and inserts it
> accordingling:
> I'm on linux:
>
>>>> import os
>>>> p = os.path.join('bob', 'bill')
>>>> p
> 'bob/bill'
>>>>
>

Worse than that, the code as posted by the OP used string concatenation 
before calling  os.path.join(), and the latter method does nothing at 
all, when presented with a single string.



-- 
DaveA

[toc] | [prev] | [next] | [standalone]


#38205

FromAnthony Correia <akcorreia@gmail.com>
Date2013-02-05 08:40 -0800
Message-ID<mailman.1372.1360083143.2939.python-list@python.org>
In reply to#38203
On Tuesday, February 5, 2013 10:17:54 AM UTC-5, pytho...@tim.thechases.com wrote:
> On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote:
> 
> > By the way, did someone ever notice that r'\' fails ? I'm sure
> 
> > there's a reason for that... (python 2.5) Anyone knows ?
> 
> > 
> 
> > r'\'
> 
> > SyntaxError: EOL while scanning single-quoted string
> 
> 
> 
> I hit this all the time with Vim's path-completion (":help
> 
> i_CTRL-X_CTRL-F") on Win32 which puts a trailing "\" on
> 
> directory-names.  I just need to remember to remove it, a task made
> 
> easier because the syntax highlighting correctly shows how Python
> 
> interprets it (i.e., the string is still continued).
> 
> 
> 
> -tkc

Sorry about that I hit the touchpad on my laptop by mistake.  Beside the using  single '\' vs a double '\\' does that look ok?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web