'RecursionError: maximum recursion depth exceeded in comparison inside class?

Here's my code:

import zlib

import funcy


class DeflateData:
    def __init__(self, data):
        self.__data = data

    @property
    def compressed_data(self):
        compressed_data = bytearray()

        for chunk in funcy.chunks(32768, self.__data):
            compressed_data += zlib.compress(chunk, 9)

        return self.compressed_data


if __name__ == "__main__":
    with open("input_file", "rb") as infile:
        data = infile.read()

    deflate = DeflateData(data)

    print(deflate.compressed_data)

It works perfectly fine as a function not part of a class; however, I put it in a class as shown, and it gives the maximum recursion error, and it is stuck in an infinite loop. I think this has something to do with self.__data repeatedly being initialized when it should only be initialized once? That's just a guess, I have no idea what seems to be off, but any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source