Re: How to parsing a sequence of integers

2008-12-19 Thread Joe Strout
Mensanator wrote: from __future__ import division at the top of the file. I put this at the top of all my Python files, whether I expect to be dividing or not. It just saves grief. If you want division to be floating point. If, like me, you rarely do floating point division and want the "/" t

Re: How to parsing a sequence of integers

2008-12-19 Thread Mensanator
On Dec 19, 9:23�am, Joe Strout wrote: > Peter Otten wrote: > > If you are using Python 2.x: > > ... > > So you better throw in a float(...): > > Or, add > > � �from __future__ import division > > at the top of the file. �I put this at the top of all my Python files, > whether I expect to be dividi

Re: How to parsing a sequence of integers

2008-12-19 Thread Joe Strout
Peter Otten wrote: If you are using Python 2.x: ... So you better throw in a float(...): Or, add from __future__ import division at the top of the file. I put this at the top of all my Python files, whether I expect to be dividing or not. It just saves grief. Cheers, - Joe -- http://

Re: How to parsing a sequence of integers

2008-12-19 Thread Peter Otten
Bruno Desthuilliers wrote: > Steven Woody a écrit : >> In additional to max/min, is there something like average()? > > Not AFAIK, but it's really trivial > > def average(lst): > """ assume lst is a list of numerics """ > return sum(lst) / len(lst) If you are using Python 2.x: >>> def

Re: How to parsing a sequence of integers

2008-12-19 Thread Bruno Desthuilliers
John Machin a écrit : On Dec 20, 12:33 am, Bruno Desthuilliers wrote: Steven Woody a écrit :> Hi, I am a newbie and is reading the python book. Could anyone tell me, how to parsing the following string "123 100 12 37 ..." > into a list of integers on which I can then apply max()/min()?

Re: How to parsing a sequence of integers

2008-12-19 Thread Steven Woody
On Fri, Dec 19, 2008 at 9:33 PM, Bruno Desthuilliers wrote: > Steven Woody a écrit : >> >> Hi, >> >> I am a newbie and is reading the python book. Could anyone tell me, >> how to parsing the following string >> "123 100 12 37 ..." > >> into a list of integers on which I can then apply max()/min

Re: How to parsing a sequence of integers

2008-12-19 Thread John Machin
On Dec 20, 12:33 am, Bruno Desthuilliers wrote: > Steven Woody a écrit :> Hi, > > > I am a newbie and is reading the python book.  Could anyone tell me, > > how to parsing the following string > >    "123 100 12 37 ..." > >  > into a list of integers on which I can then apply max()/min()? > > sour

Re: How to parsing a sequence of integers

2008-12-19 Thread Marc 'BlackJack' Rintsch
On Fri, 19 Dec 2008 21:20:48 +0800, Steven Woody wrote: > Hi, > > I am a newbie and is reading the python book. Could anyone tell me, how > to parsing the following string >"123 100 12 37 ..." > into a list of integers on which I can then apply max()/min()? In [376]: '123 100 12 37'.split()

Re: How to parsing a sequence of integers

2008-12-19 Thread Bruno Desthuilliers
Steven Woody a écrit : Hi, I am a newbie and is reading the python book. Could anyone tell me, how to parsing the following string "123 100 12 37 ..." > into a list of integers on which I can then apply max()/min()? source = "123 100 12 37" list_of_ints = [int(part) for part in source.stri

How to parsing a sequence of integers

2008-12-19 Thread Steven Woody
Hi, I am a newbie and is reading the python book. Could anyone tell me, how to parsing the following string "123 100 12 37 ..." into a list of integers on which I can then apply max()/min()? In additional to max/min, is there something like average()? Thanks in advance. - narke -- http://ma