how to remove n bytes in a file?

2006-09-02 Thread Dasn
Hi. Suppose we have a very large file, and wanna remove 'n' bytes in the middle of the file. My thought is: 1, read() until we reach the bytes should be removed, and mark the position as 'pos'. 2, seek(tell() + n) bytes 3, read() until we reach the end of the file, into a variable, say 'a' 4, seek(

Re: A problem from a Vim user

2006-08-28 Thread Dasn
On Sun, Aug 27, 2006 at 07:10:06AM -0500, Dasn wrote: > vim.command('let vim_str=input("Please type something.\n")') > py_str = vim.eval('vim_str') py_str = vim.eval('input("Please type something.\n")') may be better. -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem of function calls from map()

2006-08-28 Thread Dasn
On Tue, Aug 22, 2006 at 04:50:39PM +0200, Fredrik Lundh wrote: > (you cannot really use "profile" to *benchmark* things written in > Python either; the profiler tells you where a given program spends the > time, not how fast it is in com- parision with other programs) Thanks for your indication.

Re: A problem from a Vim user

2006-08-27 Thread Dasn
On Mon, Aug 07, 2006 at 10:59:01AM -0700, manuhack wrote: > When I use raw_input('Please type something.\n') in the python 2.4 > command line windows, it doesn't have any problem. However, when I run > the same command in vim 7 as :py raw_input('Please type something.\n'), > there is an EOFError:

Re: Problem of function calls from map()

2006-08-21 Thread Dasn
Thanks for your reply. Well, please drop a glance at my current profile report: # test.py - import os, sys, profile print os.uname() print sys.version # size of 'dict.txt' is about 3.6M, 154563 lines f = open('dict.txt', 'r') print "Reading lines..."

Problem of function calls from map()

2006-08-21 Thread Dasn
Hi, there. 'lines' is a large list of strings each of which is seperated by '\t' >>> lines = ['bla\tbla\tblah', 'bh\tb\tb', ... ] I wanna split each string into a list. For speed, using map() instead of 'for' loop. 'map(str.split, lines)' works fine , but... when I was trying: >>> l = map(str.