Ifs and assignments
Chris Angelico
rosuav at gmail.com
Thu Jan 2 23:25:21 EST 2014
On Fri, Jan 3, 2014 at 3:14 PM, Roy Smith <roy at panix.com> wrote:
> Or turn it into a generator:
> That certainly makes your mainline code cleaner...
Cleaner perhaps, but not clearer. Instead of seeing the original
function (say, a database retrieve-next call), you see a wrapper and
have to go dig to find out what it's actually doing. Unless it's some
kind of generic handler, like:
def funcinator(func,*args):
while True:
var = func(*args)
if var:
yield var
else:
break
while funcinator(cur.getnext):
....
But even that would be problematic until it got so thoroughly
understood that it's like enumerate() - which is itself still not
perfect.
ChrisA
More information about the Python-list
mailing list