Python Forum
a range of lines in a file
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a range of lines in a file
#1
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?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020