a...@pythoncraft.com (Aahz) writes: > ... >>>> def readlines(f): >>>> lines = [] >>>> while "f is not empty": >>>> line = f.readline() >>>> if not line: break >>>> if len(line) > 2 and line[-2:] == '|\n': >>>> lines.append(line) >>>> yield ''.join(lines) >>>> lines = [] >>>> else: >>>> lines.append(line) >>> >>> There's a few changes I'd make: >>> I'd change the name to something else, so as not to shadow the built-in, > ... > Actually, as an experienced programmer, I *do* think it is confusing as > evidenced by the mistake Dave made! Segregated namespaces are wonderful > (per Zen), but let's not pollute multiple namespaces with same name, > either. > > It may not be literally shadowing the built-in, but it definitely > mentally shadows the built-in.
I disagree with you. namespaces are there that in working with a namespace I do not need to worry much about other namespaces. Therefore, calling a function "readlines" is very much justified (if it reads lines from a file), even though there was a module around with name "readlines". By the way, the module is named "readline" (not "readlines"). -- http://mail.python.org/mailman/listinfo/python-list