Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10284 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2011-07-25 18:01 +0200 |
| Last post | 2011-07-25 18:01 +0200 |
| 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 Peter Otten <__peter__@web.de> - 2011-07-25 18:01 +0200
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2011-07-25 18:01 +0200 |
| Subject | Re: Trying to learn about metaclasses |
| Message-ID | <mailman.1462.1311609726.1164.python-list@python.org> |
Steven W. Orr wrote: > I have been doing a lot of reading. I'm starting to get it. I think it's > really cool as well as dangerous, but I plan on being respectful of the > construct. I found a web page that I found quite readable. > > http://cleverdevil.org/computing/78/ > > So, I tried to run the example code (below), and I get AttributeError. If > someone can get me over this hump, I'd be grateful. It complains that > Person has no _fields attribute, but the print hello I have in > EnforcerMeta doesn't happen either. Am I doing something wrong? > > I'm running python 2.6.2 > > Here's the error: > > 585 > ./meta1.py > Traceback (most recent call last): > File "./meta1.py", line 38, in <module> > swo.name = 'swo' > File "./meta1.py", line 27, in __setattr__ > if key in self._fields: > AttributeError: 'Person' object has no attribute '_fields' > And here's the code: > > class EnforcerMeta(type): > def __init(cls, name, bases, ns): You misspelt __init__()
Back to top | Article view | comp.lang.python
csiph-web