1

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
  • 48,339
  • 8
  • 43
  • 63
sam
  • 183
  • 1
  • 11

0 Answers0