Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63030
| References | <52C59FF6.5000607@allsup.co> <mailman.4816.1388709915.18130.python-list@python.org> <52c62fa8$0$30001$c3e8da3$5496439d@news.astraweb.com> <mailman.4823.1388720985.18130.python-list@python.org> <roy-9D0E6B.23144702012014@news.panix.com> |
|---|---|
| Date | 2014-01-03 15:25 +1100 |
| Subject | Re: Ifs and assignments |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4828.1388723131.18130.python-list@python.org> (permalink) |
On Fri, Jan 3, 2014 at 3:14 PM, Roy Smith <roy@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
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Ifs and assignments Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-02 19:45 -0500
Re: Ifs and assignments Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-03 14:33 +1100
Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 14:49 +1100
Re: Ifs and assignments Roy Smith <roy@panix.com> - 2014-01-02 23:14 -0500
Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 15:25 +1100
Re: Ifs and assignments Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-03 04:29 +0000
Re: Ifs and assignments Duncan Booth <duncan.booth@invalid.invalid> - 2014-01-03 15:46 +0000
Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 14:55 +1100
Re: Ifs and assignments Roy Smith <roy@panix.com> - 2014-01-02 23:00 -0500
Re: Ifs and assignments Chris Angelico <rosuav@gmail.com> - 2014-01-03 15:08 +1100
csiph-web