[PATCH 1/2] Clean up code for input handling in TUI spokes.

Brian C. Lane bcl at redhat.com
Tue Sep 3 21:35:27 UTC 2013


On Tue, Sep 03, 2013 at 08:31:58AM -0400, Samantha N. Bueno wrote:
> +        if keyid in range(0, len(self._choices)):
> +            choice = self._choices[keyid]

Why use range here instead of if keyid < len(...

The same question applies to a number of places in this patch.

> +        if keyid in range(1, len(self.parttypelist)):
> +            self.clearPartType = PARTTYPES[self.parttypelist[keyid]]

In this case you could use

if 0 < keyid < len(...):

I don't see any reason to use range for all of these comparisons, it
seems wasteful to me, creating a list each time you want to compare.


-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20130903/cc0d7b4e/attachment.sig>


More information about the anaconda-patches mailing list