Typeerror: Module._Init_() Takes at Most 2 Arguments (3 Given)

Scrapy dmoz tutorial: _init_() takes at most 2 arguments (3 given)

The problem is you're importing "spiders", and using it as your base class. "spiders" is the package that contains the spiders, namely the Spider class. To use it, use:

from scrapy.spiders import Spider

class dmozspider(Spider):
... # Rest of your code

module._init_() takes at most 2 arguments (3 given) (scrapy tutorial w/ xpath)

You have mistyped scrapy.Item class name.

In items.py, change:

scrapy.item

to

scrapy.Item

It should look like this:

import scrapy

class DmozItem(scrapy.Item):
title = scrapy.Field()
link = scrapy.Field()
desc = scrapy.Field()

TypeError: _init_() takes exactly 2 arguments (1 given)

You missed the variable dataDir here:

hw = HelloWorld('path/to/your/dir')

Python: __init__() takes 2 positional arguments but 3 were given

I think this is the line that is causing the issue, you cannot pass the self instance to the constructor.

frame = F(self, container)

Can you please check and add more information to the question to understand what you are trying to achieve.

TypeError: __init__() takes 2 positional arguments but 4 were given

Comments inside the code.

from abc import ABCMeta, abstractmethod

class Book(object, metaclass=ABCMeta): # 1. Why do you need meta class?
def __init__(self, title, author):
self.title=title
self.author=author
@abstractmethod
def display(self): pass # 2. Consider replacing with raise NotImplementedError + missing 'self'

class MyBook(Book):
def __init__(self, price, title, author): # 3 You are missing two arguments in here.... (title and author)
super(MyBook, self).__init__(title, author) # 4 This line is missing
self.price = price

def display(self):
print('Title: {}'.format(self.title)) # self missing in all three lines
print('Author: {}'.format(self.author))
print('Price: {}'.format(self.price))

title=input()
author=input()
price=int(input())
new_novel = MyBook(title, author, price)
new_novel.display()


Related Topics



Leave a reply



Submit