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
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
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
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
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
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