Re: sorting a list and counting interchanges

2005-04-07 Thread Peter Nuttall
On Wed, Apr 06, 2005 at 03:30:41PM -0700, RickMuller wrote: > I have to sort a list, but in addition to the sorting, I need to > compute a phase factor that is +1 if there is an even number of > interchanges in the sort, and -1 if there is an odd number of > interchanges. > I would just write a

Re: Delete first line from file

2005-03-01 Thread Peter Nuttall
On Tue, Mar 01, 2005 at 01:27:27PM +0100, Tor Erik S?nvisen wrote: > Hi > > How can I read the first line of a file and then delete this line, so that > line 2 is line 1 on next read? > > regards > > I think you can do something like: n=false f=file.open("") #stuff here g=[] for line in f.re

Re: Basic file operation questions

2005-02-03 Thread Peter Nuttall
On Wed, Feb 02, 2005 at 11:47:41PM -0500, Caleb Hattingh wrote: > Hi Alex > > Assuming you have a file called "data.txt": > > *** > f = open('data.txt','r') > lines = f.readlines() > f.close() > for line in lines: > print line > *** > Can you not write this: f=open("data.txt", "r") for line

Re: [perl-python] 20050125 standard modules

2005-01-25 Thread Peter Nuttall
On Tuesday 25 Jan 2005 17:50, Dan Perl wrote: > I was wrong. He is just crossposting to the newsgroups without having > them as members of the group. > > I wish there was a good way like that to stop these daily postings! > You can just filter on [perl-python] Pete -- http://mail.python.org/mai

Re: Read word tables

2004-12-21 Thread Peter Nuttall
On Tuesday 21 Dec 2004 11:24, Rameshwari wrote: > Hi, > > I would like to read a ms-word document using python. > > Basically the word document contains number of tables and the rows > in each table do not have same number of columns. > > Does anyone have a sample code to read a table? > > Thank y

Re: Operators as functions

2004-12-20 Thread Peter Nuttall
On Monday 20 Dec 2004 22:44, Anders Andersson wrote: > Hello > > I want to concatinate (I apologize for bad English, but it is not my > native language) a list of strings to a string. I could use (I think): > > s = "" > map(lambda x: s.append(x), theList) > > But I want to do something like (I thin

Re: No acceptable C compiler was found in $PATH

2004-12-20 Thread Peter Nuttall
On Monday 20 Dec 2004 03:58, banaticus wrote: > What does this error message mean? What can I do to fix it? > > Here'e the command that I just tried running, and the messages that > I received. I just barely unpacked python. > > linux:/Python-2.4 # ./configure > checking MACHDEP... linux2 > check

Re: Recursive list comprehension

2004-12-06 Thread Peter Nuttall
like this: def flatten(nested): for sublist in nested: for element in sublist: yield element n=[['N', 'F'], ['E'], ['D']] output=[] for value in flatten(n): output.append(value) print output Have a merry Christmas Peter Nuttall -- http://mail.python.org/mailman/listinfo/python-list