"import" not working?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Mar 13 19:55:52 CET 2009

En Fri, 13 Mar 2009 14:27:27 -0200, Lie Ryan <lie.1296 at gmail.com> escribió:
> Steve Holden wrote:
>> Lie Ryan wrote:
>>> Scott David Daniels wrote:
>>>> Aahz wrote:
>>>>> In article <mailman.605.1235434737.11746.python-list at python.org>,
>>>>> Rhodri James <rhodri at wildebst.demon.co.uk> wrote: ...
>>>>>> sys.path.append("C:\\DataFileTypes")
>>>>> My preference:
>>>>> sys.path.append(r"C:\DataFileTypes")
>>>>> This doesn't work if you need to add a trailing backslash, though.
>>>> Also my preference (except, due to aging eyes and bad fonts, I prefer
>>>> single quotes unless doubles are needed).  I solve the trailing
>>>> backslash problem as so:
>>>>    sys.path.append(r'C:\DataFileTypes' '\\')
>>> Why not: r'C:\DataFileTypes\ '
>>  Because that's the file named " " that lives in C:\DataFileTypes?
> Is whitespace name possible? I tried:
> os.mkdir(r'C:\somedir\ ')
> and it gives the error:
> WindowsError: [Error 183] Cannot create a file when that file already  
> exists: 'C:\\somedir\\ '
> Every single way I can think of to try to make a name with purely space  
> failed. Why not make os modules special case single whitespace folder?  
> (give better reason than to quote the Zen)

py> path = r'C:\DataFileTypes\ '
py> os.path.join(path, "hello.txt")
'C:\\DataFileTypes\\ \\hello.txt'

> anyway, you could always use r'C:\DataFileTypes\ '[:-1]

Yes, and it's one of the alternatives listed in the FAQ entry:

Gabriel Genellina

More information about the Python-list mailing list