Python Code Review: Debugging and Refactoring “Conway’s Game of Life” + Automated Tests


Video is ready, Click Here to View × ► What’s the mindset you need to master Python and write beautiful and Pythonic code?

Python Code Review: Unplugged – Episode 1: Code Review for Labeeb

This is a screencast recording of Python code review I did for newsletter member Labeeb. Follow along and you’ll see how to refactor and clean up an existing Python code base for a “Conway’s Game of Life” game to make it easier to read and more maintainable.

Note that I left the video is completely…

12 thoughts on “Python Code Review: Debugging and Refactoring “Conway’s Game of Life” + Automated Tests

  1. 16:00 After years of Python I completely forgot python object and reference semantics during a code interview exercise. Worse still 2 minutes out the door I remembered, and it made me hate the C work I'd done that month

  2. Dan, loved your "unplugged" code review. Hugely informative to watch and so many things to learn. Also a quick thanks to "Labeeb" for agreeing to share this on YT. I will go search for more Unplugged code reviews from you. Keep up the good work.

  3. Great suggestions. I have a couple additions:

    You could use a setUp method in the tests to get the same grid for testing, at least I would do that in unittest tests, but these look like pytests, so maybe you would make a simple grid factory?

    For reducing the long boolean line, you could do something like:
    negative_coords = xn < 0 or yn < 0
    outofbound_coords = nx >= len(self.life_grid) or ny >= len(self.life_grid)

    Then the bool test just looks like:
    if negative_coords or outofbound_coords:

    I also like adding a _len_ method to most classes, then the above becomes:
    outofbound_coords = nx >= len(self) or ny >= len(self)

    Hope that helps! ;D

Leave a Reply

Your email address will not be published. Required fields are marked *