kokarare1212 / librespot-python

Implicit enumerate calls found PTC-W0060
Anti-pattern
Major
3 years ago3 years old
Consider replacing range(len(product)) with enumerate(product)
 883        product = products[0]
 884        if product is None:
 885            return
 886        for i in range(len(product)): 887            self.__user_attributes[product[i].tag] = product[i].text
 888        self.logger.debug("Parsed product info: {}".format(
 889            self.__user_attributes))
Consider replacing range(len(self.alphabet)) with enumerate(self.alphabet)
110
111    def create_lookup_table(self):
112        self.lookup = bytearray(256)
113        for i in range(len(self.alphabet)):114            self.lookup[self.alphabet[i]] = i & 0xff
115
116    class CharacterSets:
Consider replacing range(len(indices)) with enumerate(indices)
 63
 64    def translate(self, indices: bytes, dictionary: bytes):
 65        translation = bytearray(len(indices))
 66        for i in range(len(indices)): 67            translation[i] = dictionary[int.from_bytes(indices[i].encode(),
 68                                                       "big")]
 69        return translation