Shiva <shivaji...@yahoo.com.dmarc.invalid> 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
 dominate.

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
 numbers.

Next are to add in the shebang and encoding commands.

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

With
    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
 exception.

Finally you could indent by 4 spaces instead of 1.

HTH


-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to