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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Python bug: Can assign [] = (), but not () = []

85 点作者 axit将近 10 年前

11 条评论

iaw将近 10 年前
I was very impressed with the collective thought process shown in the bug thread. It was quite constructive and I think demonstrative of why python has been such a successful project.
评论 #9611677 未加载
ngoldbaum将近 10 年前
This is a fun numpy quirk:<p><pre><code> &gt;&gt;&gt; &#x27;x&#x27;*3.5 Traceback (most recent call last): File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt; TypeError: can&#x27;t multiply sequence by non-int of type &#x27;float&#x27; &gt;&gt;&gt; import numpy as np &gt;&gt;&gt; print &#x27;x&#x27;*np.float64(3.5) xxx</code></pre>
评论 #9609647 未加载
评论 #9609631 未加载
评论 #9614604 未加载
agumonkey将近 10 年前
Dave Beazley gave a talk showing this. See <a href="https:&#x2F;&#x2F;twitter.com&#x2F;renfredxh&#x2F;status&#x2F;586653125970386945" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;renfredxh&#x2F;status&#x2F;586653125970386945</a>
amelius将近 10 年前
This is mostly harmless, as most people in that thread already noted.
tenfingers将近 10 年前
Using [] = to exhaust generators (as mentioned in the bug report) is actually pretty awesome in my mind.
rectangletangle将近 10 年前
&gt;&gt;&gt; [a, b] = 2, 3<p>&gt;&gt;&gt; (a, b) = 2, 3<p>&gt;&gt;&gt; {a, b} = 2, 3<p><pre><code> File &quot;&lt;interactive input&gt;&quot;, line 1 </code></pre> SyntaxError: can&#x27;t assign to literal
评论 #9609920 未加载
sparaker将近 10 年前
This is what i see in javascript:<p>[] = (); VM105:2 Uncaught ReferenceError: Invalid left-hand side in assignment<p>() = []; VM114:2 Uncaught SyntaxError: Unexpected token )
ixtli将近 10 年前
&gt; The starting point is recognizing that this has been around for very long time and is harmless.
ronbeltran将近 10 年前
I can also do this, which is harmful.<p><pre><code> &gt;&gt;&gt; True = False &gt;&gt;&gt; False = True</code></pre>
评论 #9609782 未加载
评论 #9609753 未加载
评论 #9609721 未加载
评论 #9615346 未加载
squigs25将近 10 年前
() is not a tuple. (a,b) is a tuple or (a,) would also be a tuple.
评论 #9615952 未加载
rectangletangle将近 10 年前
....__class__ # Python 3 only