Re: [BangPypers] scanf replacement in python

2011-11-07 Thread steve

On 11/06/2011 11:59 AM, kracekumar ramaraju wrote:

Hello

The question might  be simple, but it has a trick.
*
*
*c code*
*scanf(%d, %d,m,n)*

The code can accept two nos separated by a space.

*Question*: What is the equivalent in python?

*Answer 1:*
*p*

*Shortcoming*: I need press return to get o/p of second no.



Umm, isn't that the case with C too ?


*Answer 2:*
a = raw_input(no; )
#Enter two nos separated by space
a = a.split()

*Shortcoming*: it involves split function.

Is there any better way to approach the same problem.



http://effbot.org/pyfaq/is-there-a-scanf-or-sscanf-equivalent.htm
http://docs.python.org/library/re.html#simulating-scanf
http://stackoverflow.com/questions/2175080/sscanf-in-python

cheers,
- steve

--
random spiel: http://lonetwin.net/
what i'm stumbling into: http://lonetwin.stumbleupon.com/
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


Re: [BangPypers] scanf replacement in python

2011-11-07 Thread kracekumar ramaraju
On Mon, Nov 7, 2011 at 10:07 PM, steve st...@lonetwin.net wrote:

 On 11/06/2011 11:59 AM, kracekumar ramaraju wrote:

 Hello

The question might  be simple, but it has a trick.
 *
 *
 *c code*
 *scanf(%d, %d,m,n)*


 The code can accept two nos separated by a space.

 *Question*: What is the equivalent in python?

 *Answer 1:*
 *p*

 *Shortcoming*: I need press return to get o/p of second no.


 Umm, isn't that the case with C too ?

  *Answer 2:*

 a = raw_input(no; )
 #Enter two nos separated by space
 a = a.split()

 *Shortcoming*: it involves split function.


 Is there any better way to approach the same problem.


 http://effbot.org/pyfaq/is-**there-a-scanf-or-sscanf-**equivalent.htmhttp://effbot.org/pyfaq/is-there-a-scanf-or-sscanf-equivalent.htm
 http://docs.python.org/**library/re.html#simulating-**scanfhttp://docs.python.org/library/re.html#simulating-scanf
 http://stackoverflow.com/**questions/2175080/sscanf-in-**pythonhttp://stackoverflow.com/questions/2175080/sscanf-in-python

 cheers,
 - steve


Thanks :)
*
Talk is cheap, show me the code - Linus Torvalds
Winning Regards
KraceKumar.R
http://kracekumar.wordpress.com
+91-97906-58304
*
*+91-85530-29521*
*
*
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers


[BangPypers] scanf replacement in python

2011-11-06 Thread kracekumar ramaraju
Hello

   The question might  be simple, but it has a trick.
*
*
*c code*
*scanf(%d, %d, m,n)*

The code can accept two nos separated by a space.

*Question*: What is the equivalent in python?

*Answer 1:*
*a, b = int(raw_input('no 1: ')), int(raw_input('no 2: '))*

*Shortcoming*: I need press return to get o/p of second no.

*Answer 2:*
a = raw_input(no; )
#Enter two nos separated by space
a = a.split()

*Shortcoming*: it involves split function.

Is there any better way to approach the same problem.



-- 
*
Talk is cheap, show me the code - Linus Torvalds
Winning Regards
KraceKumar.R
http://kracekumar.wordpress.com
+91-97906-58304
*
*+91-85530-29521*
*
*
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers