简体   繁体   中英

Render mangled hy attribute names as regular strings

If I have an attribute self.internal/freezer in a class, and I raise an error via (raise (AttributeError f"Sorry! '{attr}' doesn't exist as an attribute!")) , how can I get the attribute name to render as internal/freezer instead of hyx_internalXsolidusXfreezer ? For example, I already tried (hy.eval attr) with the f-string , but it still came out mangled.

Thanks to @Kodiologist in the comments linking themangling section in hylang's syntax documentation ; unamgling can be achieved via the aptly named hy.unmangle function, documented here as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM