[Python-ideas] Alternate quote delimiters
Tal Einat
taleinat at gmail.com
Sun May 13 11:07:44 CEST 2007
On 5/13/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> Jim Jewett wrote:
>
> > How serious is this problem?
> >
> > r"The Windows path is C:\Foo\Bar\Baz\X"[:-1]
> >
> > is awkward, but ... how much complexity do we want to incur avoiding it?
>
> If you use os.path.join and friends to manipulate your
> paths (as you should!) you will hardly ever have to deal
> with a path containing a trailing backslash in the first
> place. So I wouldn't worry about it much.
When learning Python, new users often get bitten by this. Simple learning
exercises often leave os.path for later, and use simpler hard-coded file
paths instead. When teaching Python, this is one more sharp edge I'm forced
to warn new users about.
I also hear people complaining about this when using Python for simple
automation scripts, where hard-coded paths are common, and using os.path can
easily double the amount of code and its complexity for no extra
functionality.
(Yes, the [:-1] hack works, but it's ugly, and Python should be beautiful.)
I'm sure the "completely remove escapes from raw strings" PEP will solve
this issue, and I'm looking forward to it.
- Tal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20070513/8328c020/attachment.html>
More information about the Python-ideas
mailing list