[Tutor] HELP-Regarding python

spawgi at gmail.com spawgi at gmail.com
Wed Jan 30 08:02:58 CET 2013


missed a parenthesis, it should look like -
with open(<filepath>, <mode>) as <filehandle>:
<indent>//operation with the file.


On Wed, Jan 30, 2013 at 12:31 PM, <spawgi at gmail.com> wrote:

> A safer approach would be -
> with open(<filepath>, <mode> as <filehandle>:
> <indent>//operation with the file.
>
> This way, you do not have to remember to close the file explicitly.
>
>
> On Wed, Jan 30, 2013 at 12:27 PM, Dave Angel <davea at davea.name> wrote:
>
>> On 01/30/2013 01:51 AM, Gayathri S wrote:
>>
>>> Hi All....!
>>>                   I don't know how to read text file in python. If the
>>> data
>>> values are stored in a text file format, for
>>> example(1,30,60,90,120...200)
>>> means what i would do for reading it in python. could you just explain
>>> it.
>>>
>>>
>>>
>> infile = open("filename", "rt")    will open a text file
>>
>> line = infile.readline()        will read one line from it, as a str
>>
>> After that, you can parse it anyway you like.
>>
>>
>>
>>
>> --
>> DaveA
>> ______________________________**_________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>>
>
>
>
> --
> http://spawgi.wordpress.com
> We can do it and do it better.
>



-- 
http://spawgi.wordpress.com
We can do it and do it better.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130130/94c1e044/attachment.html>


More information about the Tutor mailing list