Re: removing nested iffs

2011-07-30 Thread Peter Otten
Chris Angelico wrote: > On Sat, Jul 30, 2011 at 6:42 AM, Peter Otten <__pete...@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): >

Re: removing nested iffs

2011-07-29 Thread Chris Angelico
On Sat, Jul 30, 2011 at 6:42 AM, Peter Otten <__pete...@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 t

Re: removing nested iffs

2011-07-29 Thread Chris Angelico
On Sat, Jul 30, 2011 at 5:40 AM, Josh Benner wrote: > I'm writing a function to create a string that gets longer iff an argument > is defined.  In there a more elegant way than nesting all those ifs? Your logic appears to be: Proceed along a specified list and stop when you find that you don't ha

Re: removing nested iffs

2011-07-29 Thread Peter Otten
Josh Benner wrote: > I'm writing a function to create a string that gets longer iff an argument > is defined. In there a more elegant way than nesting all those ifs? > > def format_rsync_src_string(args, server="RSYNC"): > """ Format an rsync source directory string. """ > if args.server

Re: removing nested iffs

2011-07-29 Thread Josh Benner
On Fri, Jul 29, 2011 at 1:07 PM, Wolfgang Rohdewald wrote: > On Freitag 29 Juli 2011, Josh Benner wrote: > > if args.build not None: > > which python version understands this? > > -- > Wolfgang > Apparently the version running in my head understands it ;-) Sorry about that how about this (replac

Re: removing nested iffs

2011-07-29 Thread Wolfgang Rohdewald
On Freitag 29 Juli 2011, Josh Benner wrote: > if args.build not None: which python version understands this? -- Wolfgang -- http://mail.python.org/mailman/listinfo/python-list