Aahz wrote:
On Tue, Apr 19, 2005, Shane Holloway (IEEE) wrote:However, my opinion is that it does not read smoothly. This form requires that I say what I'm doing with something before I know the context of what that something is. For me, blocks are not about shortening the code, but rather clarifying *intent*.
Hmmmm.... How is this different from defining functions before they're called?
It's not. In a function scope I'd prefer to read top-down. When I write classes, I tend to put the public methods at the top. Utility methods used by those entry points are placed toward the bottom. In this way, I read the context of what I'm doing first, and then the details of the internal methods as I need to understand them.
Granted I could achieve this effect with::
class Before: def readIt(self, filename): def readIt(): withFile(filename, doReading)
def doReading(aFile): self.readPartA(aFile) self.readPartB(aFile) self.readPartC(aFile)
return readIt()
Which is fine with me, but the *intent* is more obfuscated than what the block construct offers. And I don't think my crew would appreciate if I did this very often. ;)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com