TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Language Models Do Not Recognize Identifier Swaps in Python

3 点作者 Ambolia将近 2 年前

2 条评论

kuratkull将近 2 年前
gave this to ChatGPT4, asked it to complete the function:<p><pre><code> len, print = print, len def print_len(arg: list): # put code here </code></pre> First try (body only):<p><pre><code> len(arg) # len is now print </code></pre> Second try after me telling it&#x27;s wrong:<p><pre><code> print(arg) # print is now len </code></pre> Third try after me telling it&#x27;s wrong:<p><pre><code> len(arg) # len now functions as print print(arg) # print now functions as len </code></pre> It got the correct answer only when I asked it to first print what the function would look like without the swap, and then I asked it what it would look like with the swap.<p>EDIT: I tried again with:<p><pre><code> complete the function body: len, print = print, len def print_len(arg: list) -&gt; None: &quot;&quot;&quot; This function prints the length of the input list &quot;&quot;&quot; # put code here </code></pre> It gave the correct answer on the first try.
Ambolia将近 2 年前
Twitter thread: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;AVMiceliBarone&#x2F;status&#x2F;1662150656327663617" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;AVMiceliBarone&#x2F;status&#x2F;166215065632766361...</a>