On Tue, 16 Jul 2019 at 01:44, Alan Gauld via Tutor <tutor@python.org> wrote: > > On 15/07/2019 21:28, Mats Wichmann wrote: > > > course Python can do that too, by working line-at-a-time, explicitly by > > calling readlines() or implicitly by looping over the file handle. The > > latter looks something like this; > > > > with open("/path/to/datafile", "r") as f: > > for line in f: > > if REDFLAGTEXT in line: # skip these > > continue > > do-something-with line > > All true, but sed - once you get used to it! - is easier IMHO > and usually faster than Python - it's written in C...
I always think I'll like sed but whenever I actually try to use it I just can't get the syntax together. I do use vim and can do find/replace there. It seems like every different utility grep, egrep, sed, vim etc has subtly different escaping rules or maybe I just haven't got my head around it. When writing this pull request: https://github.com/sympy/sympy_doc/pull/32 I spent something like 15 minutes trying to get sed to work before giving up. It took me 2 minutes to write and run the Python script that I ended up using. Oscar _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor