2

I have a code piece in Python 3 to find the paths recursively from a directory.

 >>> import glob
  >>> glob.glob('**/*.txt', recursive=True)

Output in python 3

 ['2.txt', 'sub/3.txt']

But when I run the same code in python 2 I got this error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: glob() got an unexpected keyword argument 'recursive'

Can't I use recursive option in Python 2 ? If not then what can be the possible solution in Python2. Please suggest :-)

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
sam
  • 203
  • 1
  • 3
  • 15

0 Answers0