I would like to apply regex to the content of a file without loading the entire file into a string. The RegexObject takes as its first argument a string or a buffer. Is there any way to turn the file into a buffer?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Quote from Python doc:
And some other interesting part:
File objects does not implement buffer interface – so you have to change its content either into string (
f.read()) or into array (use mmap for that).