Re: [Tutor] looking for a pattern in a lot of files

2005-05-22 Thread Kent Johnson
Jonas Melian wrote: > any improvement about this code? > how print the actual file? You can print the file name and line number using fileinput.filename() and fileinput.filelineno() > could i add an exception? by if there aren't files Set a flag if you print anything, check it at the end of the

Re: [Tutor] looking for a pattern in a lot of files

2005-05-22 Thread Max Noel
On May 22, 2005, at 21:07, Jonas Melian wrote: > for line in fileinput.input(glob.glob(os.path.join > (dir_locales, "*_[A-Z][A-Z]"))): > if re.search("locale for", line): > print line If you're only looking for the occurrence of a string and not a regex pattern, you do

[Tutor] looking for a pattern in a lot of files

2005-05-22 Thread Jonas Melian
I've to looking for a pattern ('locale for') in a lot of files (/dir/*_[A-Z][A-Z]) it's goes ok any improvement about this code? how print the actual file? could i add an exception? by if there aren't files for line in fileinput.input(glob.glob(os.path.join (dir_locales, "*_[A-Z][A-Z]")