TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: What's your favorite Python quirk?

3 pointsby wampleralmost 9 years ago
Any unusual or unexpected feature of the language

3 comments

jordighalmost 9 years ago
There&#x27;s a nice list here:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;cosmologicon&#x2F;pywat" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cosmologicon&#x2F;pywat</a><p>Here&#x27;s another one. Compare &quot;x = 256; y = 256; x is y&quot; with &quot;x = 257&quot; (enter) &quot;y = 257&quot; (enter) &quot;x is y&quot; with &quot;x = 257; y = 257; x is y&quot;. It makes a difference whether x and y are assigned on the same line or not. From here:<p><a href="http:&#x2F;&#x2F;glasnt.com&#x2F;blog&#x2F;2016&#x2F;05&#x2F;28&#x2F;on-language-oddities.html" rel="nofollow">http:&#x2F;&#x2F;glasnt.com&#x2F;blog&#x2F;2016&#x2F;05&#x2F;28&#x2F;on-language-oddities.html</a>
评论 #11928566 未加载
wampleralmost 9 years ago
Abusing locals() - learnt it from @jroller<p>def foo(): &quot;&quot;&quot; &gt;&gt;&gt; foo() {&#x27;a&#x27;: 1, &#x27;c&#x27;: 3, &#x27;b&#x27;: 2} &quot;&quot;&quot; a = 1 b = 2 c = 3 return locals()
probinsoalmost 9 years ago
My favorite quirk was deprecated.<p>Python 2.x<p>def function(a, (b, c)): # pattern extract matches a strictly two-elements<p>Python 3.x<p>def function(a, b_c): # not as clean, nor as expressive