Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10319 > unrolled thread
| Started by | Victor Khangulov <kilka.hamsa@gmail.com> |
|---|---|
| First post | 2011-07-25 22:44 -0400 |
| Last post | 2011-07-25 22:44 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Trying to learn about metaclasses Victor Khangulov <kilka.hamsa@gmail.com> - 2011-07-25 22:44 -0400
| From | Victor Khangulov <kilka.hamsa@gmail.com> |
|---|---|
| Date | 2011-07-25 22:44 -0400 |
| Subject | Re: Trying to learn about metaclasses |
| Message-ID | <mailman.1483.1311648254.1164.python-list@python.org> |
Hi Steven,
I too am just learning about metaclasses in Python and I found the
example you posted to be excellent.
I played around with it and noticed that the issue seems to be the
double-underscore in front of the fields (cls.__fields = {}). If you
change this parameter to use the single-underscore, the code works
perfectly.
I think that because of the double-underscore, the name of the attribute
"fields" gets mangled by the interpreter and is not inherited from the
parent class in its accessible form. Now, I am not sure if the code
posted uses an earlier version of Python where these rule are different
or if there is a more correct way to achieve this. I will follow this
discussion to see if someone has a better answer.
-victor
Back to top | Article view | comp.lang.python
csiph-web