Error When Calling Metaclass Bases Python
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 python inheritance Learn more about Stack Overflow the company Business Learn more about hiring developers python class inheritance or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack error when calling the metaclass bases takes at most 2 arguments 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: Sign up Error when calling the metaclass bases: function() error when calling the metaclass bases module.__init__() takes at most 2 arguments argument 1 must be code, not str up 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 "
Error When Calling The Metaclass Bases Cannot Create A Consistent Method Resolution
metaclass bases function() argument 1 must be code, not str Can someone explain this error? Thanks! python class inheritance metaclass share|improve this question asked Feb 9 '10 at 18:24 David Underhill 11.4k44258 add a comment| 3 Answers 3 active oldest votes up vote 46 down vote accepted You're getting that exception because, despite its class-like name, threading.Condition is a function, and you cannot subclass functions. >>> type(threading.Condition)
Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any
Typeerror: Error When Calling The Metaclass Bases
questions you might have Meta Discuss the workings and policies of this typeerror error when calling the metaclass bases multiple bases have instance lay-out conflict site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or typeerror error when calling the metaclass bases object() takes no parameters posting ads with us Software Quality Assurance & Testing beta Questions Tags Users Badges Unanswered Ask Question _ Software Quality Assurance & Testing Stack Exchange is a question and http://stackoverflow.com/questions/2231427/error-when-calling-the-metaclass-bases-function-argument-1-must-be-code-not answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 http://sqa.stackexchange.com/questions/12158/typeerror-error-when-calling-the-metaclass-bases-module-init-takes-at-mos given) up vote 0 down vote favorite I'm new to coding and Python. Not sure where exactly I should be looking to fix this error. from UIMap import tomcat8LoginPage,tomcat8urls,competitors class test_Competitors(unittest): def setup(self, driver): self.driver = driver self.driver = webdriver.Firefox() self.driver.get("https://qa-tomcat8.ez-touch.net/acton/account/login.jsp") def test_Compete(self): driver = self.driver actions = ActionChains(driver) ### Log-in and navigate to Competitors page ### self.fill_out_field\ (10, driver.find_element_by_id\ (tomcat8LoginPage ['usernameField']),'username2092') self.fill_out_field\ (10, driver.find_element_by_id\ (tomcat8LoginPage['passwordField']),'Password2092') self.click\ (10, driver.find_element_by_id\ (tomcat8LoginPage ['loginBtn'])) driver.get(tomcat8urls ['newUIurl']) self. click\ (10, driver.find_element_by_xpath\ (competitors ['inboundMenu'])) selenium webdriver python share|improve this question edited Sep 14 '15 at 14:20 log_file 1,680522 asked Feb 13 '15 at 23:31 Saleh Qadan 3128 self is also argument. BTW you need to forget your annoying \ at the end of the line. Parens work just fine over multiple lines, and \ will break if someone adds a whitespace after it. Using \ for line continuation is very much against best practices in Python –Peter Masiar Feb 14 '15 at 1:01 I mean self.method(a, b) has 3 arguments: self, a, and b
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: http://forums.devshed.com/python-programming/933572-base-class-derived-class-noob-question-post2831621.html Base class and Derived class(noob question) Share This Thread Tweet This + http://www.gossamer-threads.com/lists/python/python/905168 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 error when Derived class(noob question) Hey guys, I'm trying to understand how is working base 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 error when calling get this error : Code: TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) 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 :
Post #1 of 9 (4669 views) Permalink class error I have the following file: FileInfo.py: import UserDict class FileInfo(UserDict): "store file metadata" def __init__(self, filename=None): UserDict.__init__(self) self["name"] = filename When i import it like so: import FileInfo i get this error: Traceback (most recent call last): File "