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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Adding Empty Set Literals to Python

41 点作者 philipbjorge大约 12 年前

11 条评论

rakha大约 12 年前
"I thought {@} would be a good for an empty set because it arguably looks like the empty set symbol"<p>I'm just nitpicking but I don't think this is a good justification - If the @ symbol looks like the empty set symbol, then {@} is the set containing the empty set
jrockway大约 12 年前
I personally prefer dict() to {} anyway, so I don't really miss the lack of an empty set literal.<p>Adding a set literal was a slippery slope anyway. Where's my frozenset literal? Where's my namedtuple literal?<p>(I also don't particularly like the {} syntax for dicts, because there is {'too_much': 'quoting'} which I find rather ugly. I much prefer dict(too_much='quoting') or, even better, Perl's solution: { too_much =&#62; 'quoting' }.)
评论 #5384931 未加载
raymondh大约 12 年前
Executive summary: If you don't like part of the language, it is really easy to add your own hack and make it worse ;-)<p>Really, you should trust the core developers on this one. Empty set literals are missing from Python for a reason.
评论 #5384805 未加载
评论 #5384599 未加载
polemic大约 12 年前
That ain't orthogonality, <i>this</i> is orthogonality:<p><pre><code> dict() = {} set() = &#60;&#62; tuple() = () list() = [] </code></pre> (btw, does anyone actually use `&#60;&#62;` as `!=`?)
评论 #5384948 未加载
评论 #5384885 未加载
hwiechers大约 12 年前
I think it would be best if empty dictionary was {:} and empty set was {}. Of course, it would be insane to make this change.
sciencerobot大约 12 年前
Maybe Guido doesn't like it because it looks weird when compared to the rest of Python's syntax? Still, I think it's cool. Having sets availably without importing anything is one of the things I love about Python.<p>set = &#60;&#62; is still available.
评论 #5384455 未加载
评论 #5384535 未加载
评论 #5384444 未加载
codesuela大约 12 年前
The webfont doesn't load for me because I have Ghostery installed (it blocks remote tracking scripts) so the page is all blank except for the code snippets (because Adobe Typekit is blocked). You should consider adding a fallback font.
评论 #5386078 未加载
vbtemp大约 12 年前
&#62; What I learned: It’s not always hard to make interesting changes to large projects.<p>Should be, it's not always hard to make interesting changes <i>to very well-designed and well-architected projects</i>
johnsoft大约 12 年前
I vaguely recall seeing a mailing list thread where `{-}` was proposed. I think it was rejected based on parsing ambiguity, i.e. `{-1}` vs `{-}`. (Or it's possible I might be losing my memory)
评论 #5384786 未加载
评论 #5384462 未加载
tantalor大约 12 年前
<p><pre><code> There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch.</code></pre>
评论 #5384590 未加载
SilasX大约 12 年前
Is it just me, or is it a little ... obsessive to be <i>this</i> annoyed with having to use `set()` instead of `{@}`?
评论 #5384424 未加载