On Friday 28 October 2005 06:29, Björn Lindström wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > f = open("filename", "rb") > > s = f.read() > > sub = "\x00\x00\x01\x00" > > count = s.count(sub) > > print count > > That's a lot of lines. This is a bit off topic, but I just can't stand > unnecessary local variables. > > print file("filename", "rb").read().count("\x00\x00\x01\x00")
The "f" is not terribly unnecessary, because the part of the code you didn't see was f.close() Which would be considered good practice. James -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com/ -- http://mail.python.org/mailman/listinfo/python-list