Search code examples
pythonglobraw-input

I have error while i tried to execute query which return me a path to variable


I tried to open multiple files in one location using python

When I tried to execute this small script I get error:

Traceback (most recent call last): File "", line 254, in run_nodebug File "C:\Users\kostrzew\Desktop\REPORTS\MdiAdmin.py", line 21, in file_path = glob(os.path.join(dir,"*.mdi")) TypeError: 'module' object is not callable

import os
import string
import re
import sys
import glob


src = raw_input("Enter source disk location: ")
src = os.path.dirname(src)
for dir,_,_ in os.walk(src):
    file_path = glob(os.path.join(dir,"*.mdi"))
    print(file_path)

Solution

  • glob is the name of the module, the name of the function is glob.glob.

    file_path = glob.glob(os.path.join(dir,"*.mdi"))