简体   繁体   English

将损坏的 hy 属性名称呈现为常规字符串

[英]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 ?如果我在self.internal/freezer属性,并且我通过(raise (AttributeError f"Sorry! '{attr}' doesn't exist as an attribute!"))引发错误,我该如何获取要呈现为internal/freezer而不是hyx_internalXsolidusXfreezer的属性名称? For example, I already tried (hy.eval attr) with the f-string , but it still came out mangled.例如,我已经用f-string尝试过(hy.eval attr) ,但它仍然被破坏了。

Thanks to @Kodiologist in the comments linking themangling section in hylang's syntax documentation ;感谢@Kodiologist 在评论中链接了hylang 语法文档中的 mangling 部分 unamgling can be achieved via the aptly named hy.unmangle function, documented here as well.可以通过恰当命名的unamgling function 来实现hy.unmangle此处也有文档说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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