Python

Помогите с программой на Python

ошибка Traceback (most recent call last):
File "C:\Users\march\PycharmProjects\pythonProject1\УСОВЕРШЕНСТВОВАННАЯ.py", line 44, in <module>
mov_file.shutil(a=input("Начальная директория : "),b=input("Расширение файла : "),move_file=input("Куда копировать файл") , operation = shutil.copy)
TypeError: move_files_and_copy.shutil() missing 1 required positional argument: 'self'

вот код :
import os
import shutil

class move_files_and_copy(object):
def __init__(self,a,b,move_file,operation):
self.a = a
self.b = b
self.move_file = move_file
self.operation = operation
def shutil(self,a,b,move_file,operation):
a = self.a
n = os.listdir(a)
numbers = 0
for i in n:
file_name = i

s = ""
s = i
for g in s:
if g == ".":
s = ""
else:
s = s + g

if s == b:
self.operation((a + "\\" + file_name), self.move_file)
numbers += 1
print(n)
print("Перемещено", numbers, "Файлов с расширением", b)


massiv = ["Копирование","Перемещение"]

print("Выберите операцию из списка ниже")
n = 0
for text in massiv:
print(text + "-" + str(n))
n = n + 1

number_opertion = int(input("Введите номер операции : "))

if number_opertion == 0:
mov_file = move_files_and_copy
mov_file.shutil(a=input("Начальная директория : "),b=input("Расширение файла : "),move_file=input("Куда копировать файл") , operation = shutil.copy)


elif number_opertion == 1:
mov_file = move_files_and_copy
mov_file.shutil(a=input("Начальная директория : "),b=input("Расширение файла : "),move_file=input("Куда перемещать файл") , operation = shutil.copy)
import os
import shutil

class move_files_and_copy(object):
def __init__(self, a, b, move_file, operation):
self.a = a
self.b = b
self.move_file = move_file
self.operation = operation

def shutil(self, a, b, move_file, operation):
a = self.a
n = os.listdir(a)
numbers = 0
for i in n:
file_name = i
s = ""
s = i
for g in s:
if g == ".":
s = ""
else:
s = s + g

if s == b:
self.operation((a + "\\" + file_name), self.move_file)
numbers += 1
print(n)
print("Перемещено", numbers, "Файлов с расширением", b)

massiv = ["Копирование", "Перемещение"]

print("Выберите операцию из списка ниже")
n = 0
for text in massiv:
print(text + "-" + str(n))
n = n + 1

number_opertion = int(input("Введите номер операции: "))

if number_opertion == 0:
mov_file = move_files_and_copy(a=input("Начальная директория: "), b=input("Расширение файла: "), move_file=input("Куда копировать файл: "), operation=shutil.copy)
mov_file.shutil(a, b, move_file, operation=shutil.copy)

elif number_opertion == 1:
mov_file = move_files_and_copy(a=input("Начальная директория: "), b=input("Расширение файла: "), move_file=input("Куда перемещать файл: "), operation=shutil.move)
mov_file.shutil(a, b, move_file, operation=shutil.move)
АГ
Азер Гаджиев
1 388
Лучший ответ
import os
import shutil

class move_files_and_copy(object):
def __init__(self,a,b,move_file,operation):
self.a = a
self.b = b
self.move_file = move_file
self.operation = operation

def shutil(self): # убрать аргументы a, b, move_file, operation
a = self.a
n = os.listdir(a)
numbers = 0
for i in n:
file_name = i

s = ""
s = i
for g in s:
if g == ".":
s = ""
else:
s = s + g

if s == self.b: # заменить b на self.b
self.operation((a + "\\" + file_name), self.move_file)
numbers += 1
print(n)
print("Перемещено", numbers, "Файлов с расширением", self.b)

massiv = ["Копирование","Перемещение"]

print("Выберите операцию из списка ниже")
n = 0
for text in massiv:
print(text + "-" + str(n))
n = n + 1

number_opertion = int(input("Введите номер операции : "))

if number_opertion == 0:
mov_file = move_files_and_copy(a=input("Начальная директория : "),b=input("Расширение файла : "),move_file=input("Куда копировать файл") , operation = shutil.copy)
mov_file.shutil() # вызов метода объекта mov_file

elif number_opertion == 1:
mov_file = move_files_and_copy(a=input("Начальная директория : "),b=input("Расширение файла : "),move_file=input("Куда перемещать файл") , operation = shutil.move)
mov_file.shutil() # вызов метода объекта mov_file