re search through a text Vs line

Dave Angel davea at
Sun Oct 5 22:12:52 CEST 2014

Shiva <shivaji_tn at> Wrote in message:
> OK,
> Hi Dave,
> I modified it as below and it works....(If there is a way to make this more
> efficient please let me know)

Deends on what you mean by efficiency. 

The big memory efficiency gain was when you got rid of either the
 read or readlines.

Performance is pretty irrelevant,  since disk I/O, unicode
 processing,  and terminal processing are likely to

Programmer efficiency is usually more important than either of those.

First thing is to pick better names, and/or comment what the
 cryptic names mean. And avoid any names that look like

Next are to add in the shebang and encoding commands.

You could replace
   fileextract = open(fullfilename,'r')

    with  open(fullfilename,'r') as fileextract:

And indent the code that uses the file. That way it's clearer, you
 don't need the separate close, and it will be closed no matter
 how you leave that scope,  whether a return statement or

Finally you could indent by 4 spaces instead of 1.



More information about the Python-list mailing list