'How can I glob all files (with and without extension) in python using pathlib and glob

I want to create a list of all files in a directory using pathlib's glob. The file names may have an extension (ex.: 'text.txt', 'abc.csv') or not ('text', 'abc'). I do realize that this can be handled by the same solution which is the answer to 'How to glob two patterns with pathlib?' but at the moment I cannot believe that something so simple has no simple solution (though it is difficult to understand why glob doesn't allow a list of patterns).

Edit:

  • The file names are just examples; so filtering for them is not my goal.
  • There is a solution using two calls of glob and adding the results. The question is more specific: is there a simpler solution.
  • using the pattern '**/*' is including all subdirectories, which is not intended
  • using os.listdir only shifts the problem: now you have to filter out the directories.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source