0

I'm trying to find out what is the best way to use the wild cards in Python. I'm trying to migrate this piece of .ks code to .py. If any file in a folder exists. I was thinking using these alternatives like: glob os.path.exists = but this will turn true or false os.path.isfile len? Here is part my code.

#this is .ks
fail_flag=0
#Checking more than one file of any kind
files=$(ls /opt/flag/*)  
for file in $file
do
 if [ -f $file ] ; then
  fail_flag=1
 fi
done
pirulo
  • 335
  • 1
  • 5
  • 13
  • Does this answer your question? [Use wildcard with os.path.isfile()](https://stackoverflow.com/questions/4296138/use-wildcard-with-os-path-isfile) – SKPS Apr 19 '23 at 01:32

1 Answers1

1

If I understood you correctly, you can use python glob. Something like that:

import glob
if glob.glob('//opt//flag//*.*'):
   return True

Here is the docs - https://docs.python.org/2/library/glob.html

xmp
  • 104
  • 1
  • 4