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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Metaclasses in Python

158 点作者 fogus超过 13 年前

7 条评论

darklajid超过 13 年前
Previously: <a href="https://news.ycombinator.com/item?id=2860031" rel="nofollow">https://news.ycombinator.com/item?id=2860031</a>
lang超过 13 年前
I find metaclasses philosophically unsound. If one introduces metaclasses, what about meta-metaclasses, meta-meta-metaclasses. In this regard Self's prototypical oop seems more coherent - there are only objects. Even object/class duality looks philosophically more attractive than object/class/metaclass trio.
评论 #3360740 未加载
prolepunk超过 13 年前
Is it me or the first metaclass example doesn't work.<p>I'm using Python 2.7.2+ on Debian and I can't get __metaclass__ force upper case attributes inside of a 'module'
grunar超过 13 年前
tl;dr don't use metaclasses
评论 #3357380 未加载
lang超过 13 年前
If I'm not mistaken the authors of Smalltalk realized that metaclasses were a mistake long before they appeared in Python. Yet they were added to Python anyway.
emehrkay超过 13 年前
Python is a very cool language. I wonder if using __metaclass__ in some fashion would allow for javascript-like prototyping.
评论 #3357218 未加载
评论 #3356613 未加载
评论 #3356637 未加载
eschulte超过 13 年前
If you find yourself doing things like this in Python you should probably switch to Ruby.