[Tutor] regex and parsing through a semi-csv file
Mina Nozar
nozarm at triumf.ca
Tue Oct 25 19:38:31 CEST 2011
Thank you Ramit. I updated my code since I am running 2.7.1+ on Ubuntu.
Best wishes,
Mina
On 11-10-25 08:02 AM, Prasad, Ramit wrote:
>> f = open(args.fname, 'r')
>> lines = f.readlines()
>> f.close()
>
> If you are using Python 2.6+ you can use a context manager to automatically close the file. That way you never have to worry about closing any files!
>
> with open(args.fname, 'r') as f:
> lines = f.readlines()
>
> Ramit
>
> Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
> 712 Main Street | Houston, TX 77002
> work phone: 713 - 216 - 5423
>
> --
>
> This email is confidential and subject to important disclaimers and
> conditions including on offers for the purchase or sale of
> securities, accuracy and completeness of information, viruses,
> confidentiality, legal privilege, and legal entity disclaimers,
> available at http://www.jpmorgan.com/pages/disclosures/email.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list