0

Was looking for a method to delete files using a wildcard. Came across this question which helped me out. I thought the accepted answer was easier to understand and that's the method I would prefer.

However, it looks like the answer which utilizes the glob module is considerably more popular. What are the possible reasons for this? Is there an advantage that this method has over the accepted answer?

Community
  • 1
  • 1
Aaron
  • 483
  • 1
  • 6
  • 17
  • I would have posted a comment on the answer but 1. I don't have the reputation required and 2. It seemed more like a question – Aaron Jul 29 '16 at 19:12
  • The asker appears to have had some issues getting `glob` to work, so did not accept it. – chepner Jul 29 '16 at 19:34
  • Yes, I see that, but I guess I was trying to point out the difference in upvotes received by the two answers as an indicator of the more popular answer. – Aaron Jul 29 '16 at 20:00

1 Answers1

0

There should be one-- and preferably only one --obvious way to do it.

The one obvious way to find all path names that match a pattern is the glob module, since that is what it is documented to do.

The accepted answer implements a subset of glob's functionality, it can find all files ending in .txt. It is not wrong, but it is not the One Way.

James K
  • 3,692
  • 1
  • 28
  • 36