Need to know if a file as only ASCII charaters

Wolfgang Rohdewald wolfgang at rohdewald.de
Tue Jun 16 23:13:11 EDT 2009


On Wednesday, 17. June 2009, Steven D'Aprano wrote:
>         while text:
>             for c in text:
>                 if c not in printable: return False

that is one loop per character.

wouldn't it be faster to apply a regex to text?
something like

while text:
	if re.search(r'\W',text): return False

-- 
Wolfgang



More information about the Python-list mailing list