Help with first script please. files, directories, autocomplete

Gabriel Genellina gagsl-py at yahoo.com.ar
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)
>['.Config.pm.swp', '.run.bat.swp', 'AHK scripts', 'Archive',
>'Config.pm', '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
listdir(d)

or

import os
os.listdir(d)

-- 
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! 
http://www.yahoo.com.ar/respuestas




More information about the Python-list mailing list