a range of lines in a file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: a range of lines in a file (/thread-26026.html) |
a range of lines in a file - Skaperen - Apr-19-2020 would it be reasonably natural to specify a range on lines in a file (in a function or method call, or on the command line of a script) in the same way, numerically, that a range of items in a list is referenced? if you load a file into a list ... with open(filename) as f filelines = [x for x in f]... you can use slicing on the list to reference a range of lines. but what would make most sense as arguments or options in a command script considering that many users of the command are Python coders and/or many are not? and what about havin options to be given a search/match string? |