Error When Calling Metaclass Bases
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about error when calling the metaclass bases python Stack Overflow the company Business Learn more about hiring developers or posting ads with
Error When Calling The Metaclass Bases Youtube
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a
Error When Opening Internet Explorer
community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error when calling the metaclass bases: function() argument 1 must be code, not str up
Error When Calling The Metaclass Bases Takes At Most 2 Arguments
vote 29 down vote favorite 1 I tried to subclass threading.Condition earlier today but it didn't work out. Here is the output of the Python interpreter when I try to subclass the threading.Condition class: >>> import threading >>> class ThisWontWork(threading.Condition): ... pass ... Traceback (most recent call last): File "
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies error when calling the metaclass bases cannot create a consistent method resolution of this site About Us Learn more about Stack Overflow the company typeerror error when calling the metaclass bases object() takes no parameters Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges typeerror error when calling the metaclass bases __init__() keywords must be strings Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/2231427/error-when-calling-the-metaclass-bases-function-argument-1-must-be-code-not Sign up TypeError: Error when calling the metaclass bases a new-style class can't have only classic bases up vote 8 down vote favorite A collection of classes defined as: class A(): @staticmethod def call(): print('a') class C(type): def __repr__(self): return 'somename' class B(A): __metaclass__ = C @staticmethod def call(): print('b') def boundcall(self): print('bound') When run, gives this error: TypeError: Error when calling http://stackoverflow.com/questions/9677163/typeerror-error-when-calling-the-metaclass-bases-a-new-style-class-cant-have-o the metaclass bases a new-style class can't have only classic bases I need the metaclass (I think) to have a known string representation of B in my code. Reason for having that is beside the point but it'll greatly help with future updates. So assuming I need C to be the metaclass of B and B will be a subclass of A can someone tell me what is going wrong here and how I might change what I'm doing to remove the error? python oop typeerror new-style-class share|improve this question edited Dec 21 '14 at 3:28 bignose 10k63561 asked Mar 13 '12 at 1:27 rutherford 3,011113065 add a comment| 1 Answer 1 active oldest votes up vote 12 down vote accepted The problem is the line class A(): It should be: class A(object): That way, you make A a new style class. The empty parens make no sense whatsoever, and still, I continue to see them on stackoverflow and everywhere. Why, oh why? share|improve this answer answered Mar 13 '12 at 1:37 pillmuncher 6,52221926 add a comment| Your Answer draft saved draft d
Search Username Password Remember Me? Register Lost Password? facebook google twitter rss Free Web Developer Tools Advanced Search Forum Programming Languages Python Programming Base class and Derived class(noob question) Thread: Base class and Derived class(noob question) Share http://forums.devshed.com/python-programming/933572-base-class-derived-class-noob-question-post2831621.html This Thread Tweet This + 1 this Post To Linkedin Subscribe to this Thread Subscribe to This Thread November 6th, 2012,07:00 AM #1 No Profile Picture Cyberika View Profile View Forum Posts Registered User Devshed Newbie (0 - 499 posts) Join Date Nov 2012 Posts 2 Rep Power 0 Base class and Derived class(noob question) Hey guys, I'm trying to understand how is working base error when class and derived class. So, I have to files baseClass.py and derivedClass.py. baseClass.py : Code: class baseClass(): def bFunction(self): print "We are in a base class" derivedClass.py: Code: import baseClass as baseClassMod reload(baseClassMod) class derivedClass(baseClassMod): def dFunction(self): print "We are in a derived Class" buwhen I'm trying to run derivedClass.py I get this error : Code: TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) error when calling Interesting thing is that if I run baseClass.py and then run : Code: class derivedClass(baseClass): def dFunction(self): print "We are in a derived Class" It works fine Faq Reply With Quote November 6th, 2012,08:51 AM #2 Schol-R-LEA View Profile View Forum Posts Commie Mutant Traitor Devshed Intermediate (1500 - 1999 posts) Linkedin Join Date Jun 2004 Location Alpharetta, GA Posts 1,809 Rep Power 1572 The issue is that you are changing the name of the imported module, but not the imported class. In order to do what you seem to want, you would either have to refer to the BaseClassMod explicitly: Code: import baseClass as baseClassMod reload(BaseClassMod) class derivedClass(baseClassMod.baseClass): def dFunction(self): print "We are in a derived Class" or import the class name with an as clause: Code: from baseClass import baseClass as baseClassMod reload(BaseClassMod) class derivedClass(baseClassMod): def dFunction(self): print "We are in a derived Class" Comments on this post Cyberika agrees : Realy elpfull post! Thank you! Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF #define KINSEY (rand() % 7) λ Scheme is the Red Pill Scheme in Short • Understanding the C/C++ Preprocessor Taming Python • A Hi