Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make python class "ast.literal_eval()" compatible?

I have my custom class that represents an object. I want to make that object compatible with "ast.literal_eval()"

How can I do that? I can add necessary method/code to my class if necessary.

like image 972
leopoodle Avatar asked Apr 13 '26 13:04

leopoodle


1 Answers

You cannot. You will need to reimplement it from scratch, adding support for your class within it.

like image 147
Ignacio Vazquez-Abrams Avatar answered Apr 15 '26 03:04

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!