0

I have an Uuter class with few instaces variables and i want to set one to the Inner class. The code :

class AutoComplete :
    
    def __init__(self, ocr_all_doc_text , pdf_id, connection ) :
        self.ocr_text   = ocr_all_doc_text
        self.pdf_id     = pdf_id
        self.connection = connection
        
        self.dataregex = self.DataRegex(self, ocr_all_doc_text)
        

    def show(self):
        print(self.pdf_id)
        
    class DataRegex :
        
        def __init__(self, ocr_all_doc_text) :
            self.ocr_all_doc_text = ocr_all_doc_text
    
        def get_tva_list_from_string(self,) :
            pass

I get this error : AutoComplete.DataRegex.__init__() takes 2 positional arguments but 3 were given when I run

auto_complete = AutoComplete(ocr_all_doc_text = text_ocr_all, pdf_id = pdf_id, connection=connection)
    
# GET LIST TVA  OCR
data = auto_complete.dataregex
print(data)

I do not get the fact that I gave 3 positional arguments.

Thank you

Goncalves
  • 159
  • 9
  • 3
    In the same way that you didn't passing in `self` to `AutoComplete()`, you don't need to pass self into `DataRegex()` when creating it. – Loocid Dec 15 '22 at 23:59

0 Answers0