[blivet:master 12/20] Make a method terser
Anne Mulhern
amulhern at redhat.com
Tue Apr 15 15:42:42 UTC 2014
----- Original Message -----
> From: "Brian C. Lane" <bcl at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Monday, April 14, 2014 8:43:52 PM
> Subject: Re: [blivet:master 12/20] Make a method terser
>
> On Fri, Apr 11, 2014 at 02:03:54PM -0400, mulhern wrote:
> > This was prompted by some pylint complaints about variable names.
> >
> > Signed-off-by: mulhern <amulhern at redhat.com>
> > ---
> > blivet/devices.py | 10 +++-------
> > 1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/blivet/devices.py b/blivet/devices.py
> > index 2671e88..dfe05ad 100644
> > --- a/blivet/devices.py
> > +++ b/blivet/devices.py
> > @@ -1926,13 +1926,9 @@ class DMDevice(StorageDevice):
> >
> > @property
> > def status(self):
> > - _status = False
> > - for map in block.dm.maps():
> > - if map.name == self.mapName:
> > - _status = map.live_table and not map.suspended
> > - break
> > -
> > - return _status
> > + return next((m.live_table and not m.suspended \
> > + for m in block.dm.maps() if m.name == self.mapName),
> > + False)
> >
> > def updateSysfsPath(self):
> > """ Update this device's sysfs path. """
> > --
> > 1.8.3.1
>
> Terse and I think much harder to understand what it is doing.
>
>
> --
> Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA
> (PST8PDT)
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
>
Generally speaking, I find the new version far clearer, mostly
because it's using next, which is more specific, and no identifiers
instead of a for-loop, which is more general, and three identifiers
all of which affect the return value.
I've withdrawn this patch from the set.
- mulhern
More information about the anaconda-patches
mailing list