Code Point
September 10, 2010, 06:44:04 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Geshi Sintax Hilighting Mod Installed. Tens of languages available.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Listing directory files  (Read 2699 times)
Cobra
Jr. Member
*

Karma: 0
Offline Offline

Posts: 3


« on: September 15, 2006, 12:44:08 AM »

I want to list all files in a directory but I'm getting an error:

Code
>>> import glob
>>> for file_name in glob(r'*'):
...     print file_name
...
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
TypeError: 'module' object is not callable
Logged
Cario Face
Jr. Member
*

Karma: 1
Offline Offline

Posts: 3


« Reply #1 on: September 15, 2006, 12:49:06 AM »

The glob() method of the glob module must be qualified with the module name:

Code
>>> for file_name in glob.glob(r'*')

Otherwise the interpreter will try to call the module itself.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!