Re: find string in file

2008-03-14 Thread eMko
An of course, you can use a regular expression. (Module "re").
-- 
http://mail.python.org/mailman/listinfo/python-list


deleting a line from a file

2008-03-29 Thread eMko
Hello,

In Perl, using a Tie::File module I can easily and comfortably delete
a line from the middle of a text file:

  my @file;
  open(DATA, "+<:encoding(utf8):raw" , "file.txt") or return 0;
  tie @file, 'Tie::File', \*DATA or return 0;
  splice(@file, $_[0], 1);
  untie @file;
  close DATA;

(when the first argument of the function ($_[0]) is a number of the
line which should be deleted)

Is there some easy way how to delete a line from a middle of a file in
Python?

Thanks a lot
eMko
-- 
http://mail.python.org/mailman/listinfo/python-list