DEV Community

Cover image for We are the Borg

We are the Borg

Matt Eland on September 07, 2019

We are the Borg. Lower your shields and surrender your ships. We will add your biological and technological distinctiveness to our own. Your cultu...
Collapse
 
nuculabs_dev profile image
Nucu Labs

When I first read the title I was thinking of the borg pattern in Python

Collapse
 
integerman profile image
Matt Eland

Tell me about that. I'm not familiar with it.

Collapse
 
nuculabs_dev profile image
Nucu Labs • Edited
class Borg:
    __shared_state = {}
    def __init__(self):
        self.__dict__ = self.__shared_state

In Python you can override the built-in __dict__ attribute with your own dictionary. The __dict__ holds all the attributes of the Borg class and __shared_state is a static variable. When instantiating a Borg class __init__ is called and it overrides the __dict__ with the static __shared_state, thus each class will have the same brain: __shared_state. If you modify variables, their values will be reflected in __shared_state. :D

Collapse
 
avalander profile image
Avalander

That was a fun read and an odd simile, thank you!

Collapse
 
integerman profile image
Matt Eland

Thanks for the comment. It was fun to write. That's been rattling around in my head for a bit now.


Ha ha! Absolutely a simile.

In no way was I suggesting we actively co-opt and absorb humanity into our hive mind. Any allegations as to that sort of behavior would be promptly denied and any relevant evidence hidden.

Resistance is futile.