Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10552 > unrolled thread

Re: removing nested iffs

Started byChris Angelico <rosuav@gmail.com>
First post2011-07-30 07:48 +1000
Last post2011-07-30 07:48 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: removing nested iffs Chris Angelico <rosuav@gmail.com> - 2011-07-30 07:48 +1000

#10552 — Re: removing nested iffs

FromChris Angelico <rosuav@gmail.com>
Date2011-07-30 07:48 +1000
SubjectRe: removing nested iffs
Message-ID<mailman.1638.1311976141.1164.python-list@python.org>
On Sat, Jul 30, 2011 at 6:42 AM, Peter Otten <__peter__@web.de> wrote:
> def format_pairs(pairs):
>    for template, value in pairs:
>        if value is None:
>            break
>        yield template.format(value)
>

Cool! May I suggest a trifling change:

def format_pairs(*pairs):
	for template, value in pairs:
		if value is None: break
		yield template.format(value)

That way, the call can dispense with the [] in the argument list. This
is a pretty clean solution though, I like it.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web