Apr-24-2020, 04:23 PM
(Apr-24-2020, 03:42 PM)Jeff900 Wrote: You need to understand that when you run import calculus, the code will run. After that you could create an Tentativa() object. You can use the __init__ for that of write an function for it. When using __init__, the class can look like this.
class Tentativa(): def __init__(self, soma, count, col_data, col_new, lin_new, filename): self.soma = soma self.count = count self.col_data = col_data self.col_new = col_new self.lin_new = lin_new self.filename = filenameThen after importing the class you can create an object. Like this.
obj = calculus.Tentativa(1, 2, 3, 4, 5, 'filename')You can use obj.filename as reference to the filename now. Does this solve your problem?
Yes! It works. I just had to put in __init__ and in the function "calculo" here:
def calculo(self): import openpyxl as xl filename = self.filename #<------ also put here wb = xl.load_workbook(filename) sheet = wb['Sheet1'] #this is objectThank you so much!!!