You can do this:

==== START
import sys

for line in sys.stdin:
        print line.strip()
==== STOP

or this:

==== START
import sys

l = sys.stdin.readline()
while l != '':
        print l ,
        l = sys.stdin.readline()
==== STOP

or even this:

==== START
try:
    while True:
        l = raw_input()
        print l
except EOFError:
    pass
==== STOP


14 апреля 2012 г. 2:58 пользователь vivek dhiman
<[email protected]> написал:
> Hi luke
>
> it is simple how will  you read till end of file ?
>
> "in" is this file
> --------------------
> 1
> 2
> 3
> ----------------------
> stop reading at 3.
>
>
> On Sat, Apr 14, 2012 at 2:05 AM, Luke Pebody <[email protected]> wrote:
>>
>> I still don't understand the question, I'm afraid.
>>
>> On Fri, Apr 13, 2012 at 7:48 PM, vivek dhiman <[email protected]>
>> wrote:
>> > hey guys! How are you reading till end of file ?
>> >
>> > I mean suppose you are writing reading using comand line
>> >
>> > python hello.py <in > out
>> >
>> > what will be the contents of hello.py if we want to sop reading once we
>> > are
>> > at end of file...
>> >
>> > "in" is this file
>> > --------------------
>> > 1
>> > 2
>> > 3
>> > ----------------------
>> >
>> > # in this example 3 is our last line
>> >
>> > what should I write in hello.py
>> >
>> >
>> >
>> >
>> > On Sat, Apr 14, 2012 at 12:11 AM, preetam shivaram
>> > <[email protected]>
>> > wrote:
>> >>
>> >> yup... i luv it
>> >>
>> >>
>> >> On 14 April 2012 00:10, vivek dhiman <[email protected]> wrote:
>> >>>
>> >>> thank you guys...set as env variable and it is really cool and awesome
>> >>> thanks a lot guys :)
>> >>>
>> >>> btw any one uses notepad++??
>> >>>
>> >>>
>> >>> On Sat, Apr 14, 2012 at 12:03 AM, preetam shivaram
>> >>> <[email protected]> wrote:
>> >>>>
>> >>>> Dude use simple python file handling.. eother specify the input and
>> >>>> output file name inside ur program(code)... or use argv for
>> >>>> commandline
>> >>>> arguement.. watever the case u have the file names... read from .in
>> >>>> fil>process>write to the .out file.. as simple as that
>> >>>>
>> >>>>
>> >>>> On 13 April 2012 23:45, nischay nahata <[email protected]> wrote:
>> >>>>>
>> >>>>> You could use <.in files and >.out files from the command line (eg.
>> >>>>> "python hello.py<bla.in >bla.out" didn't test it though), else you
>> >>>>> can use
>> >>>>> the corresponding file operations (just google "reading a file in
>> >>>>> python")
>> >>>>>
>> >>>>>
>> >>>>> On Fri, Apr 13, 2012 at 11:39 PM, vivek dhiman
>> >>>>> <[email protected]>
>> >>>>> wrote:
>> >>>>>>
>> >>>>>> Hi all python lovers ..
>> >>>>>> so my question is .. i guess to every one who is running python on
>> >>>>>> windows
>> >>>>>>
>> >>>>>> How r u running python programs?
>> >>>>>> I think of 1 case
>> >>>>>> 1st case
>> >>>>>> 1. you write code in  a file(say abc.py) using notepad++/jedit
>> >>>>>> 2.  then go to cmd prompt.. type python abc.py and run..
>> >>>>>> but how do you give "in and out" files ?
>> >>>>>> Are you defining variable inside the code i mean one file variable
>> >>>>>> for
>> >>>>>> " in" and one for "out" and fixing the file names. Are you doing
>> >>>>>> this ?
>> >>>>>>  or are you doing something else??
>> >>>>>>
>> >>>>>> Or are you doing something totally different from command line ??
>> >>>>>>
>> >>>>>> Just help me out saying that you do it like this .. or may be if u
>> >>>>>> have some youtube video link or something that is also ok..
>> >>>>>>
>> >>>>>> --
>> >>>>>> You received this message because you are subscribed to the Google
>> >>>>>> Groups "Google Code Jam" group.
>> >>>>>> To post to this group, send email to [email protected].
>> >>>>>> To unsubscribe from this group, send email to
>> >>>>>> [email protected].
>> >>>>>> For more options, visit this group at
>> >>>>>> http://groups.google.com/group/google-code?hl=en.
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> --
>> >>>>> With Regards
>> >>>>>
>> >>>>> Nischay Nahata
>> >>>>> B.tech 3rd year
>> >>>>> Department of Information Technology
>> >>>>> NITK,Surathkal
>> >>>>>
>> >>>>> --
>> >>>>> You received this message because you are subscribed to the Google
>> >>>>> Groups "Google Code Jam" group.
>> >>>>> To post to this group, send email to [email protected].
>> >>>>> To unsubscribe from this group, send email to
>> >>>>> [email protected].
>> >>>>> For more options, visit this group at
>> >>>>> http://groups.google.com/group/google-code?hl=en.
>> >>>>
>> >>>>
>> >>>> --
>> >>>> You received this message because you are subscribed to the Google
>> >>>> Groups "Google Code Jam" group.
>> >>>> To post to this group, send email to [email protected].
>> >>>> To unsubscribe from this group, send email to
>> >>>> [email protected].
>> >>>> For more options, visit this group at
>> >>>> http://groups.google.com/group/google-code?hl=en.
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Regards
>> >>> Vivek Dhiman
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google
>> >>> Groups
>> >>> "Google Code Jam" group.
>> >>> To post to this group, send email to [email protected].
>> >>> To unsubscribe from this group, send email to
>> >>> [email protected].
>> >>> For more options, visit this group at
>> >>> http://groups.google.com/group/google-code?hl=en.
>> >>
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Google Code Jam" group.
>> >> To post to this group, send email to [email protected].
>> >> To unsubscribe from this group, send email to
>> >> [email protected].
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/google-code?hl=en.
>> >
>> >
>> >
>> >
>> > --
>> > Regards
>> > Vivek Dhiman
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Google Code Jam" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > For more options, visit this group at
>> > http://groups.google.com/group/google-code?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Code Jam" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-code?hl=en.
>>
>
>
>
> --
> Regards
> Vivek Dhiman
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to