[Tutor] looking for a pattern in a lot of files
Kent Johnson
kent37 at tds.net
Mon May 23 04:25:30 CEST 2005
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 loop
Kent
>
>
> for line in fileinput.input(glob.glob(os.path.join
> (dir_locales, "*_[A-Z][A-Z]"))):
> if re.search("locale for", line):
> print line
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list