Skip to content
Advertisement

Extending dictionary with cascading methods

I am extending the dict class in python:

JavaScript

I would like to be able to do:

JavaScript

the problem I have here is that jmespath can return a list, so I cannot do:

JavaScript

Next idea would be creating a prettyprint class that superDict would inherit from and could also be used in the return of search:

JavaScript

But I can’t figure out what the prettyprint class would look like for this to work. I basically can’t think of an elegant way to do this. Maybe some logic in init around the arg type would be simpler?

Advertisement

Answer

I ended up using new

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement