Skip to Content
Perl To Python Migration
book

Perl To Python Migration

by Martin C. Brown
November 2001
Beginner
320 pages
5h 53m
English
Pearson Business
Content preview from Perl To Python Migration

FILE PROCESSING

The basic processes of opening a file have already been covered in Chapters 4 and 8. Once the file has been opened you end up with a file object which is then used to access the information from the file. The methods supported by a file object closely mimic the functions and operators we would normally use in Perl and other oddities, such as using line based input (as opposed to free-form or byte based input) are supported natively by the file object.

The basic Perl functions and equivalent Python file methods are listed in Table 11.1. We'll have a look at the specifics of reading, writing, and locating our position within a file in this section.

Table 11.1. Reading and writing files in Perl and Python
Perl operation Python equivalent ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl in a Nutshell

Perl in a Nutshell

Nathan Patwardhan, Ellen Siever, Stephen Spainhour
Perl by Example

Perl by Example

Ellie Quigley
Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe

Publisher Resources

ISBN: 0201734885Purchase book