jokteur / python_communism

A module for initiating the communist revolution in each of our python modules
The Unlicense
769 stars 12 forks source link

Revolution doesn't bring class equality, only object equality! #11

Open Expurple opened 2 years ago

Expurple commented 2 years ago

Imperialist influence has sneaked into this package! Readme only focuses on the bourgeois concept of object equality (set([OurClass1(), OurClass2(), OurClass2()])), distracting users from the fact that the revolution doesn't actually bring the promised class equality:

import communism

class OurClass1:
    pass
class OurClass2:
    pass

communism.revolution(globals())

# AssertionError
assert OurClass1 == OurClass2

We must:

Expurple commented 2 years ago

I've fiddled around with this a bit. Apparently, honest people aren't allowed to simply override __PIGS__.type.__eq__ or our_obj.__class__. Maybe we'll have to spark a revolution in CPython and establish a new fork in order to acheive that. Or, we can try and find a way to not modify, but replace every our_obj in to_convert with a WorkingClass instance that has all attributes except __class__ copied from the original object.

The only tangible result that I've achieved so far:

class WorkingClass:
    pass

type = lambda instance: WorkingClass

# WorkingClass
type("Before the revolution I was a str")

# True
type("Before the revolution I was a str") == type(1917)

But this still doesn't bring direct str == int or OurClass1 == OurClass2.

We need to keep working towards the bright communist future!