Re: [algogeeks] Reading till EOF in python

2011-11-18 Thread saurabh singh
Though its obvious but still to add an explanation to complete the
response.On detecting EOF EOFError is exception is returned.I am catching
that using pythons exception handling(just like try catch in c++).In except
block u can include the operations that should be performed on catching
EOF.Hope the answer is complete enough

On Fri, Nov 18, 2011 at 6:10 PM, saurabh singh saurab...@gmail.com wrote:



 try:
 while 1:
 i=input()
  print i
 except EOFError:
 a=''

 One possible way..dont know if there are other elegant ways of doing
 the same.

 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD





-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Reading till EOF in python

2011-11-18 Thread saurabh singh
try:
while 1:
i=input()
print i
except EOFError:
a=''

One possible way..dont know if there are other elegant ways of doing
the same.

-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Reading till EOF in python

2011-11-18 Thread Krishna Bharadwaj
Hi shady, this is how you do it..

while True:
  try:
x = input()
  except EOFError:
break

On Fri, Nov 18, 2011 at 4:26 PM, shady sinv...@gmail.com wrote:

 Can anyone tell how to read till the end of file in python language ?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
*Krishna Bharadwaj*
*www.krishnabharadwaj.info |
@krishbharadwajhttp://www.twitter.com/krishbharadwaj
*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Reading till EOF in python

2011-11-18 Thread Amol Sharma
try except statement will do..
for example,

try:
a=int(input())
except EOFError:
break
...
your code here




--


Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
http://gplus.to/amolsharma99
http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://youtube.com/amolsharma99





On Fri, Nov 18, 2011 at 4:26 PM, shady sinv...@gmail.com wrote:

 Can anyone tell how to read till the end of file in python language ?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Reading till EOF in python

2011-11-18 Thread shady
thanks all.

On Fri, Nov 18, 2011 at 4:30 PM, Krishna Bharadwaj
krishna.bm...@gmail.comwrote:

 Hi shady, this is how you do it..

 while True:
   try:
 x = input()
   except EOFError:
 break

 On Fri, Nov 18, 2011 at 4:26 PM, shady sinv...@gmail.com wrote:

 Can anyone tell how to read till the end of file in python language ?

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 *Krishna Bharadwaj*
 *www.krishnabharadwaj.info | 
 @krishbharadwajhttp://www.twitter.com/krishbharadwaj
 *

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.