Help with first script please. files, directories, autocomplete

Gabriel Genellina gagsl-py at
Tue Oct 10 02:02:31 CEST 2006

At Saturday 7/10/2006 16:34, Rainy wrote:

>You can store the dir name as a variable:
> >>> d = 'c:\home'
> >>> from os import *
> >>> listdir(d)
>['', '.run.bat.swp', 'AHK scripts', 'Archive',
>'', 'Docs', 'Images', 'Links', 'Music', 'Projects', 'Python
>programs', 'run.bat', 'Share', 'Torrent']

Note that \ is a escape character, and works fine in this case only 
because \h is not a valid sequence.
Use instead 'c:\\home' or r'c:\home' or 'c:/home' (forward slashes 
are fine in Windows too)

from ... import * is not the recommended way; use instead:

from os import listdir


import os

Gabriel Genellina
Softlab SRL 

Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!

More information about the Python-list mailing list