[Tutor] listdir

Alan Gauld alan.gauld at blueyonder.co.uk
Tue Jan 13 04:05:23 EST 2004


> >>> import os

This makes the name 'os' available to Python.

> >>> listdir('C:\Documents and Settings\Christstopher
> Spears\My Documents\python')
> NameError: name 'listdir' is not defined

But Python does not know the names of anything inside os.
To use a function within os you must prefix the function name 
with os, thus:

>>> os.listdir(....)

The "Simple Sequences" and "Modules and Functions" topics 
in my tutorial address this issue in more depth.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list