Consider iterating the dictionary directly instead of calling .keys()
37 self.num_workers = num_workers
38
39 if url is None:
40 if lang in DOWNLOAD_URL.keys(): 41 self.url = DOWNLOAD_URL[lang]
42 else:
43 raise ValueError('There is no voxforge URL present for language {}!'.format(lang))
Consider iterating the dictionary directly instead of calling .keys()
179
180 is_valid_wav = os.path.isfile(wav_path) and ext == '.wav' \
181 and idx not in self.invalid_utterance_ids
182 has_transcription = basename in prompts.keys()183
184 if is_valid_wav and has_transcription:
185 if issuer.idx not in corpus.issuers.keys():
Description
Consider iterating the dictionary directly instead of calling .keys()
.
Using for key in dictionary
would always iterate the dictionary keys.
Bad practice
sounds = {"cow": "moo", "dog": "bark"}
for key in sounds.keys():
print(key)
Recommended
sounds = {"cow": "moo", "dog": "bark"}
for key in sounds:
print(key)