[英]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.