Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75338
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'base.': 0.05; '21,': 0.07; 'class,': 0.07; "subject:' ": 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'adjustments': 0.16; 'arg):': 0.16; 'callable': 0.16; 'metaclasses': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:object': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'error': 0.23; 'skip:" 40': 0.26; 'pass': 0.26; 'code:': 0.26; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; "skip:' 10": 0.31; 'file': 0.32; 'class': 0.32; 'probably': 0.32; '(most': 0.33; 'skip:_ 10': 0.34; 'common': 0.35; 'hi,': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'making': 0.63; 'object:': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: TypeError: 'NoneType' object is not callable |
| Date | Tue, 29 Jul 2014 09:21:13 +0200 |
| Organization | None |
| References | <a733ac63-f850-4f69-ac80-4095dd6e70a2@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p57bd9121.dip0.t-ipconnect.de |
| User-Agent | KNode/4.11.5 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12404.1406618499.18130.python-list@python.org> (permalink) |
| Lines | 65 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1406618499 news.xs4all.nl 2914 [2001:888:2000:d::a6]:55570 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:75338 |
Show key headers only | View raw
Satish ML wrote:
> Hi,
>
> TypeError: 'NoneType' object is not callable? Why this error and what is
> the solution? Code:
> class SuperMeta:
> def __call__(self, classname, supers, classdict):
> print('In SuperMeta.call: ', classname, supers, classdict,
> sep='\n...') Class = self.__New__(classname, supers, classdict)
> self.__Init__(Class, classname, supers, classdict)
> class SubMeta(SuperMeta):
> def __New__(self, classname, supers, classdict):
> print('In SubMeta.new: ', classname, supers, classdict,
> sep='\n...') return type(classname, supers, classdict)
> def __Init__(self, Class, classname, supers, classdict):
> print('In SubMeta init:', classname, supers, classdict,
> sep='\n...') print('...init class object:',
> list(Class.__dict__.keys()))
> class Eggs:
> pass
> print('making class')
> class Spam(Eggs, metaclass=SubMeta()):
> data = 1
> def meth(self, arg):
> pass
> print('making instance')
> X = Spam()
>
> print('data:', X.data)
> Output:
> making class
> In SuperMeta.call:
> ...Spam
> ...(<class '__main__.Eggs'>,)
> ...{'meth': <function Spam.meth at 0x0000000003539EA0>, '__module__':
> '__main__', '__qualname__': 'Spam', 'data': 1} In SubMeta.new:
> ...Spam
> ...(<class '__main__.Eggs'>,)
> ...{'meth': <function Spam.meth at 0x0000000003539EA0>, '__module__':
> '__main__', '__qualname__': 'Spam', 'data': 1} In SubMeta init:
> ...Spam
> ...(<class '__main__.Eggs'>,)
> ...{'meth': <function Spam.meth at 0x0000000003539EA0>, '__module__':
> '__main__', '__qualname__': 'Spam', 'data': 1} ...init class object:
> ['meth', '__module__', 'data', '__doc__'] making instance
> Traceback (most recent call last):
> File "C:/Users/Satish/Desktop/Python/Metaclasses7.py", line 21, in
> <module>
> X = Spam()
> TypeError: 'NoneType' object is not callable
As I have no idea what you are up to I can only list some adjustments you
probably need to make:
- __init__() and __new__() are spelt in lowercase.
- do not instantiate the metaclass:
class Spam(Eggs, metaclass=SubMeta):
...
- The metaclasses of Spam and Eggs must share a common base.
This can be achieved with
class SuperMeta(type):
...
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
TypeError: 'NoneType' object is not callable Satish ML <satishmlwizpro@gmail.com> - 2014-07-28 23:49 -0700 Re: TypeError: 'NoneType' object is not callable Peter Otten <__peter__@web.de> - 2014-07-29 09:21 +0200
csiph-web