Re: suggestions for improving code fragment please

2013-02-28 Thread Steven D'Aprano
On Thu, 28 Feb 2013 19:47:12 +, The Night Tripper wrote: > Hi there > I'm being very dumb ... how can I simplify this fragment? I suggest that the best way to simplify that fragment is to change the design of your class so it isn't so horrible. As it stands now, your class defines an ar

Re: suggestions for improving code fragment please

2013-02-28 Thread The Night Tripper
Hi All thanks very much for the various suggestions - very helpful. I think I like one of the 'just catch the exception' approaches, or using Mitya's helper function, which I was clutching towards myself. Either way, lots of food for thought. This forum really is one of the best places aroun

Re: suggestions for improving code fragment please

2013-02-28 Thread Tim Chase
On 2013-02-28 16:28, Dave Angel wrote: > On 02/28/2013 03:37 PM, Tim Chase wrote: > >for attr in ("myparm1", "myparm2", "myparm3", ...): > > if arglist: > >setattr(self, attr, arglist.pop(0)) > > else: > >break > > > Or something like (untested): > > for name, va

Re: suggestions for improving code fragment please

2013-02-28 Thread Terry Reedy
On 2/28/2013 2:47 PM, The Night Tripper wrote: Hi there I'm being very dumb ... how can I simplify this fragment? if arglist: arglist.pop(0) if arglist: self.myparm1 = arglist.pop(0) if arglist: self.

Re: suggestions for improving code fragment please

2013-02-28 Thread Dave Angel
On 02/28/2013 03:37 PM, Tim Chase wrote: On 2013-02-28 19:47, The Night Tripper wrote: Hi there I'm being very dumb ... how can I simplify this fragment? if arglist: arglist.pop(0) if arglist: self.myparm1 = arglist.pop(0)

Re: suggestions for improving code fragment please

2013-02-28 Thread Mitya Sirenef
On 02/28/2013 02:47 PM, The Night Tripper wrote: Hi there > I'm being very dumb ... how can I simplify this fragment? > > > if arglist: > arglist.pop(0) > if arglist: > self.myparm1 = arglist.pop(0) > if arglist: > self.myparm2 = arglist.pop(0) > if arglist: > self.myparm3 = arglist.pop(0) > if

Re: suggestions for improving code fragment please

2013-02-28 Thread MRAB
On 2013-02-28 19:47, The Night Tripper wrote: Hi there I'm being very dumb ... how can I simplify this fragment? if arglist: arglist.pop(0) if arglist: self.myparm1 = arglist.pop(0) if arglist: self.m

Re: suggestions for improving code fragment please

2013-02-28 Thread Tim Chase
On 2013-02-28 19:47, The Night Tripper wrote: > Hi there > I'm being very dumb ... how can I simplify this fragment? > > > if arglist: > arglist.pop(0) > if arglist: > self.myparm1 = arglist.pop(0) > if arglist: >

Re: suggestions for improving code fragment please

2013-02-28 Thread Rick Johnson
On Thursday, February 28, 2013 1:47:12 PM UTC-6, The Night Tripper wrote: > I'm being very dumb ... how can I simplify this fragment? > > if arglist: > arglist.pop(0) > if arglist: > self.myparm1 = arglist.pop(0) > if arglist: >

Re: suggestions for improving code fragment please

2013-02-28 Thread Joel Goldstick
On Thu, Feb 28, 2013 at 2:47 PM, The Night Tripper wrote: > Hi there > I'm being very dumb ... how can I simplify this fragment? > i = 0 while arglist: self.myparm[i] = arglist.pop(0) i += 1 > if arglist: > arglist.pop(0) > if arglist: >

Re: suggestions for improving code fragment please

2013-02-28 Thread Ian Kelly
On Thu, Feb 28, 2013 at 12:47 PM, The Night Tripper wrote: > Hi there > I'm being very dumb ... how can I simplify this fragment? > > > if arglist: > arglist.pop(0) > if arglist: > self.myparm1 = arglist.pop(0) > if arglist: >

suggestions for improving code fragment please

2013-02-28 Thread The Night Tripper
Hi there I'm being very dumb ... how can I simplify this fragment? if arglist: arglist.pop(0) if arglist: self.myparm1 = arglist.pop(0) if arglist: self.myparm2 = arglist.pop(0) if arglist: