Re: formatted input

2010-09-07 Thread Kenny Meyer
Bob (roberto.pagli...@gmail.com) wrote: > Hi All, > I have another question about formatted input. Suppose I am reading a > text file, and that I want it to be something like this > > word11 = num11, word12 = num12, word13 = num13 etc... > word21 = num21, word22 = num12,

Re: formatted input

2010-09-07 Thread Diez B. Roggisch
Bob writes: > Hi All, > I have another question about formatted input. Suppose I am reading a > text file, and that I want it to be something like this > > word11 = num11, word12 = num12, word13 = num13 etc... > word21 = num21, word22 = num12, word23 = num23 etc... > et

formatted input

2010-09-07 Thread Bob
Hi All, I have another question about formatted input. Suppose I am reading a text file, and that I want it to be something like this word11 = num11, word12 = num12, word13 = num13 etc... word21 = num21, word22 = num12, word23 = num23 etc... etc... where wordx1 belongs to a certain dictionary of

Re: Formatted input function

2009-09-05 Thread candide
Günther Dietrich a écrit : > > RTFM! :) > > In the python 2.5 manual: Chapter 4.2.6 (search pattern 'scanf' on the > index tab of python25.chm) Correct !! For once ;) the Manual gives an inambiguous answer : -- Simulating scanf() .-- Python does not currently have an equ

Re: Formatted input function

2009-09-05 Thread Chris Rebert
On Sat, Sep 5, 2009 at 8:00 AM, Terry Reedy wrote: > Chris Rebert wrote: >> >> On Sat, Sep 5, 2009 at 3:13 AM, candide wrote: >>> >>> I have a text file and the first line provides the best score of a game. >>> This >>> line has  the following format : >>> >>> Best score : 42 >>> >>> In order to up

Re: Formatted input function

2009-09-05 Thread Günther Dietrich
candide wrote: >In C, we would manage this with the following statement : > >fscanf(foo_file, "Best score : %d", &score); > >Does Python provide an equivalent ? RTFM! :) In the python 2.5 manual: Chapter 4.2.6 (search pattern 'scanf' on the index tab of python25.chm) There are some scanf-pat

Re: Formatted input function

2009-09-05 Thread Terry Reedy
Chris Rebert wrote: On Sat, Sep 5, 2009 at 3:13 AM, candide wrote: I have a text file and the first line provides the best score of a game. This line has the following format : Best score : 42 In order to update the score, I try to retrieve the score value. In C, we would manage this with th

Re: Formatted input function

2009-09-05 Thread Chris Rebert
On Sat, Sep 5, 2009 at 3:13 AM, candide wrote: > I have a text file and the first line provides the best score of a game. This > line has  the following format : > > Best score : 42 > > In order to update the score, I try to retrieve the score value. > > In C, we would manage this with the followin

Formatted input function

2009-09-05 Thread candide
I have a text file and the first line provides the best score of a game. This line has the following format : Best score : 42 In order to update the score, I try to retrieve the score value. In C, we would manage this with the following statement : fscanf(foo_file, "Best score : %d", &score);

Re: Formatted Input

2007-03-12 Thread Larry Bates
Deep wrote: > Hi all, > I am a newbie to python > I have an input of form > space > ie. > 4 3 > how can i assign these numbers to my variables?? > Or with list comprehension: n1, n2 = [int(n) for n in raw_input().split()] Neither of these methods checks for errors (e.g. non-integers) -Larry

Re: Formatted Input

2007-03-10 Thread Frank
On Mar 10, 11:28 am, "Deep" <[EMAIL PROTECTED]> wrote: > Hi all, > I am a newbie to python > I have an input of form > space > ie. > 4 3 > how can i assign this to my variables?? Hi, you could use: aux = f.readline() # read a line from your input file new_aux = string.split(aux, ' ') # you ca

Re: Formatted Input

2007-03-10 Thread Dan Bishop
On Mar 10, 1:29 pm, "Deep" <[EMAIL PROTECTED]> wrote: > Hi all, > I am a newbie to python > I have an input of form > space > ie. > 4 3 > how can i assign these numbers to my variables?? n1, n2 = map(int, raw_input().split()) -- http://mail.python.org/mailman/listinfo/python-list

Formatted Input

2007-03-10 Thread Deep
Hi all, I am a newbie to python I have an input of form space ie. 4 3 how can i assign these numbers to my variables?? -- http://mail.python.org/mailman/listinfo/python-list

Formatted Input

2007-03-10 Thread Deep
Hi all, I am a newbie to python I have an input of form space ie. 4 3 how can i assign this to my variables?? -- http://mail.python.org/mailman/listinfo/python-list