Wednesday, January 30, 2013

Redis PubSub wrapper for Python

Recently I've found that there's no reasonable simple and useful Redis pub sub examples around. So, here is my dead simple wrapper how to implement it without any unnecessary overhead.


  1. "This is not a class. It's looks like a class, the name is in noun, 'greeting', ok that's kind of class like. It takes arguments and stores data in __init__(), all right that's kind of class like. It has a method that uses that state to do something else, all right that feels like a class.
    This is not a class, or it shouldn't be a class."

    You know where this is from? This is from a Python core developer. He said this in a talk called "Stop Writing Classes":

    1. Ahaha, yeah, indeed. It can be something like

      But it rather looks like black magic. The one of purposes why I use classes is to keep my code easy readable. Concept of the classes fit my concern very well.

    2. I think you misunderstod what the previous author meant.
      The point is, you have only two methods that share a redis connection and a string, so they can be just that: two functions without a class. No need to put them in a class and no need to emulate class behavior.
      And of course god forbid you CamelName your functions :)