santinic / pampy

Pampy: The Pattern Matching for Python you always dreamed of.
MIT License
3.51k stars 125 forks source link

Possibilty to match same object #51

Open sunbit opened 4 years ago

sunbit commented 4 years ago

Matching an instance of a class against it's class works perfectly but i just realied that you cannot match with the class itself:

class Marker: pass
match({"my_marker": Marker}, {"my_marker": Marker}, lambda x: print('MATCH'))

I think this should be a valid match right? Looking at the code at

https://github.com/santinic/pampy/blob/master/pampy/pampy.py#L59

seems like here we should add a check based on

inspect.isclass

What do you think?