Looping ------- Collection ++++++++++ .. tab:: ✅ Good .. literalinclude:: ../../_static/idioms/loop_collection.py :language: python3 :start-after: # Good :end-before: # Bad .. tab:: ❌ Bad .. literalinclude:: ../../_static/idioms/loop_collection.py :language: python3 :start-after: # Bad .. tab:: 🎭 Compare .. literalinclude:: ../../_static/idioms/loop_collection.py :language: python3 **💡 learnt from:** * Source: `Raymond Hettinger`_ * Reference: `Transform Python Slides`_ Numbers ++++++++ .. tab:: ✅ Good .. literalinclude:: ../../_static/idioms/loop_numbers.py :language: python3 :start-after: # Good :end-before: # Bad .. tab:: ❌ Bad .. literalinclude:: ../../_static/idioms/loop_numbers.py :language: python3 :start-after: # Bad .. tab:: 🎭 Compare .. literalinclude:: ../../_static/idioms/loop_numbers.py :language: python3 **💡 learnt from:** * Source: `Raymond Hettinger`_ * Reference: `Transform Python Slides`_ Enumerate +++++++++ .. tab:: ✅ Good .. literalinclude:: ../../_static/idioms/enumerate.py :language: python3 :start-after: # Good :end-before: # Bad .. tab:: ❌ Bad .. literalinclude:: ../../_static/idioms/enumerate.py :language: python3 :start-after: # Bad .. tab:: 🎭 Compare .. literalinclude:: ../../_static/idioms/enumerate.py :language: python3 **💡 learnt from:** * Source: `Raymond Hettinger`_ * Reference: `Transform Python Slides`_ Reverse +++++++ .. tab:: ✅ Good .. literalinclude:: ../../_static/idioms/reverse.py :language: python3 :start-after: # Good :end-before: # Bad .. tab:: ❌ Bad .. literalinclude:: ../../_static/idioms/reverse.py :language: python3 :start-after: # Bad .. tab:: 🎭 Compare .. literalinclude:: ../../_static/idioms/reverse.py :language: python3 **💡 learnt from:** * Source: `Raymond Hettinger`_ * Reference: `Transform Python Slides`_ Two Collections +++++++++++++++ .. tab:: ✅ Good .. literalinclude:: ../../_static/idioms/loop_two_collections.py :language: python3 :start-after: # Good :end-before: # Bad .. tab:: ❌ Bad .. literalinclude:: ../../_static/idioms/loop_two_collections.py :language: python3 :start-after: # Bad .. tab:: 🎭 Compare .. literalinclude:: ../../_static/idioms/loop_two_collections.py :language: python3 **💡 learnt from:** * Source: `Raymond Hettinger`_ * Reference: `Transform Python Slides`_ Sentinel ++++++++ .. tab:: ✅ Good .. literalinclude:: ../../_static/idioms/sentinel.py :language: python3 :start-after: # Good :end-before: # Bad .. tab:: ❌ Bad .. literalinclude:: ../../_static/idioms/sentinel.py :language: python3 :start-after: # Bad .. tab:: 🎭 Compare .. literalinclude:: ../../_static/idioms/sentinel.py :language: python3 **💡 learnt from:** * Source: `Raymond Hettinger`_ * Reference: `Transform Python Slides`_ .. _Raymond Hettinger: https://github.com/rhettinger .. _Transform Code into Beautiful, Idiomatic Python: https://www.youtube.com/watch?v=OSGv2VnC0go> .. _Transform Python Slides: https://speakerdeck.com/pyconslides/transforming-code-into-beautiful-idiomatic-python-by-raymond-hettinger-1