News for hackers. Stuff that matters.
Re:End-to-end implementation of a machine learning pipeline ... by aportnoy on Thursday October 25, 2018 @02:43AM (#18298970)
A more Pythonic way do to this would be

    id_to_name = {g['id']: g['name'] for g in list_of_genres}
And

    for i in range(len(list_of_genres))
is really a dangerous antipattern better replaced with

    for genre in list_of_genres:
Re:End-to-end implementation of a machine learning pipeline ... by stuartaxelowen on Thursday October 25, 2018 @04:05AM (#18299288)
And if you need the index:

    for idx, genre in enumerate (list_of_genres)
Re:End-to-end implementation of a machine learning pipeline ... by mattkrause on Thursday October 25, 2018 @09:50AM (#18300853)
Out of curiosity, how is that dangerous?
Re:End-to-end implementation of a machine learning pipeline ... by tonyarkles on Thursday October 25, 2018 @11:22AM (#18301583)
My guess is based on Python 2, where range(n) would return a fully inflated list of 0..(n-1). If len(x) is large, you could be allocating giant temporary lists just to iterate through them once. Using xrange() was the Python 2 solution (it would return a generator instead), but, if I recall correctly, Python 3 fixed this s.t. range() returns a generator.