[英]How to include Hy code into a separate file, and then import that using Hy?
[英]Valid Hy Code throws an unexpected end of input error?
這是我正在編寫的游戲代碼的一部分。
(for [sprite self.sprites]
(if (!= (type sprite.content) NoneType)
(sprite.content.render)))
它抱怨parse error for pattern macro 'if': got unexpected end of input, expected: some(...)
,即使因此是有效的 Hy 代碼。
在 PyPy 上運行 Hy 版本 0.25.0,在 CPython 上運行 0.24.0 和 0.25.0。 仍然拋出同樣的錯誤。 代碼根本不應該拋出錯誤,因為它昨天工作得很好,我今天回來它會拋出一個錯誤,盡管沒有任何變化。
事實上,這不是有效的 Hy 代碼。 正如錯誤消息所建議的, if
需要第三個參數。 請參閱if
上的手冊條目。
至於這段代碼如何“昨天工作得很好”,我沒有任何解釋,除非你昨天使用的是不同版本的 Hy。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.