Python Forum

Full Version: Super with Sublime Text - TypeError: super() takes at least 1 argument (0 given)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I am trying to use the super function. I am getting the following message;

Error:
File "/Users/shaneshomefolder/Documents/Lists/numercial lists /inheratence_take_2.py", line 41, in __init__ super().__init__(make, model, backlight, battery, screentype) TypeError: super() takes at least 1 argument (0 given)
I am trying to follow a lesson online and am following the instructions exactly and continue to get this error. my code is
##30/04/19
##Shane Flanagan
##increment atrabutes through method

class Ereader():
	"""A class to represent an ereader"""

	def __init__ (self, make, model, backlight, battery, screentype):
		"""inatilase the atributes to represent an ererader"""
		self.make=make
		self.model=modle
		self.backlight=backlight
		self.battery=battery
		self.screentype=screentype 
		self.libararycount=0

	def get_ereader_name(self):
		"""return a formatted description for our ereader"""
		long_name = self.make + " - " + self.model + " - " +self.backlight + " - " + self.battery + "-" + self.screentype
		return long_name.title()

	def read_libarary_count(self):
		print("You Have " + str(self.libararycount) + " books in your libarary")


	def update_laibary_count(self, ebook_count):
		"""set the libary count"""
		self.libararycount=ebook_count

	def increment_libary_count(self, purchesed_ebooks):
		"""add new ebboks to libary count"""
		self.libararycount+=purchesed_ebooks

class KindleFire(Ereader):
	"""represents aspects of an ereader spicific to a kindle fire
		then initilaze atributes spicfic to a kindle fire"""
	def __init__(self, make, model, backlight, battery, screentype):
		"""initilize atributes of kindle fire"""
		

		super().__init__(make, model, backlight, battery, screentype)


my_kindle_fire = KindleFire('amazon', 'kindle fire', 'backlight', 'long life', 'color screen')
print(my_kindle_fire.get_ereader_name())
self.model=modle model is spelt wrong here in the __init__ of Ereader
with that corrected i don't get your error.
i get
Output:
Amazon - Kindle Fire - Backlight - Long Life-Color Screen
that is exactly the out put i am trying to get but i still get the error even with the correction. strange!! i am using Sublime Text.

Output:
Traceback (most recent call last): File "/Users/shaneshomefolder/Documents/Lists/numercial lists /inheratence_take_2.py", line 44, in <module> my_kindle_fire = KindleFire('amazon', 'kindle fire', 'backlight', 'long life', 'color screen') File "/Users/shaneshomefolder/Documents/Lists/numercial lists /inheratence_take_2.py", line 41, in __init__ super().__init__(make, model, backlight, battery, screentype) TypeError: super() takes at least 1 argument (0 given) [Finished in 0.2s with exit code 1] [shell_cmd: python -u "/Users/shaneshomefolder/Documents/Lists/numercial lists /inheratence_take_2.py"] [dir: /Users/shaneshomefolder/Documents/Lists/numercial lists ] [path: /Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

it works when i put it in my IDE. Odd!
Is Sublime Text configured to using python 2, in which it would require super(KindleFire, self).__init__(make, model, backlight, battery, screentype) hence the error.
How can i change the configuration from Python 2 to 3?
Thats great Yoriz.. thank you!!