Package: add-methods-and-properties-to-existing-object
Add methods and properties to an existing object$pipinstalladd-methods-and-properties-to-existing-objectfromadd_methods_and_properties_to_existing_objectimportAddMethodsAndPropertiesclassNewClass(AddMethodsAndProperties):#inherit from AddMethodsAndProperties to add the method add_methodsdef__init__(self):self.bubu=5def_delete_files(self,file):#some random methodsprint(f"File will be deleted:{file}")defdelete_files(self,file):self._delete_files(file)def_copy_files(self,file,dst):print(f"File will be copied:{file}Dest:{dst}")defcopy_files(self,file,dst):self._copy_files(file,dst)def_create_files(self,file,folder):print(f"File will be created:{file}{folder}")defcreate_files(self,file,folder):self._create_files(file,folder)defmethod_with_more_kwargs(self,file,folder,one_more):print(file,folder,one_more)returnselfnc=NewClass()dict_all_files={r"C:\Windows\notepad.exe_delete":{"function":"delete_files","args":(),"kwargs":{"file":r"C:\Windows\notepad.exe"},"this_args_first":True,},r"C:\Windows\notepad.exe_argsfirst":{"function":"delete_files","args":(),"kwargs":{"file":r"C:\Windows\notepad.exe"},"this_args_first":True,},r"C:\Windows\notepad.exe_copy":{"function":"copy_files","args":(),"kwargs":{"file":r"C:\Windows\notepad.exe","dst":r"C:\Windows\notepad555.exe",},"this_args_first":True,},r"C:\Windows\notepad.exe_create":{"function":"create_files","args":(),"kwargs":{"file":r"C:\Windows\notepad.exe","folder":"c:\\windows95"},"this_args_first":True,},r"C:\Windows\notepad.exe_upper":{"function":str.upper,"args":(r"C:\Windows\notepad.exe",),"kwargs":{},"this_args_first":True,},r"C:\Windows\notepad.exe_method_with_more_kwargs":{"function":"method_with_more_kwargs","args":(),"kwargs":{"file":r"C:\Windows\notepad.exe","folder":"c:\\windows95"},"this_args_first":True,},r"C:\Windows\notepad.exe_method_with_more_kwargs_as_args_first":{"function":"method_with_more_kwargs","args":(r"C:\Windows\notepad.exe","c:\\windows95"),"kwargs":{},"this_args_first":True,},r"C:\Windows\notepad.exe_method_with_more_kwargs_as_args_last":{"function":"method_with_more_kwargs","args":(r"C:\Windows\notepad.exe","c:\\windows95"),"kwargs":{},"this_args_first":False,},"this_is_a_list":[55,3,3,1,4,43],}nc.add_methods(dict_all_files)print(nc.C_Windows_notepad_exe_delete)print(nc.C_Windows_notepad_exe_delete(),end="\n\n")print(nc.C_Windows_notepad_exe_argsfirst)print(nc.C_Windows_notepad_exe_argsfirst(),end="\n\n")print(nc.C_Windows_notepad_exe_copy)print(nc.C_Windows_notepad_exe_copy(),end="\n\n")print(nc.C_Windows_notepad_exe_create)print(nc.C_Windows_notepad_exe_create(),end="\n\n")print(nc.C_Windows_notepad_exe_upper)print(nc.C_Windows_notepad_exe_upper(),end="\n\n")print(nc.C_Windows_notepad_exe_method_with_more_kwargs)print(nc.C_Windows_notepad_exe_method_with_more_kwargs(one_more="f:\\blaaaaaaaaaaaaaaaaaaaaaaaa").C_Windows_notepad_exe_method_with_more_kwargs(one_more="f:\\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ").C_Windows_notepad_exe_method_with_more_kwargs(one_more="f:\\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"),end="\n\n",)print(nc.C_Windows_notepad_exe_method_with_more_kwargs_as_args_first)print(nc.C_Windows_notepad_exe_method_with_more_kwargs_as_args_first("f:\\blaaaaaaaaaaaaaaaaaaaaaaaa"),end="\n\n",)print(nc.C_Windows_notepad_exe_method_with_more_kwargs_as_args_first("f:\\blaaaaaaaaaaaaaaaaaaaaaaaa").C_Windows_notepad_exe_method_with_more_kwargs_as_args_first("f:\\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ").C_Windows_notepad_exe_method_with_more_kwargs_as_args_first("f:\\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"),end="\n\n",)print(nc.C_Windows_notepad_exe_method_with_more_kwargs_as_args_last)print(nc.C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\blaaaaaaaaaaaaaaaaaaaaaaaa").C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ").C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"),end="\n\n",)print(nc.C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\blaaaaaaaaaaaaaaaaaaaaaaaa").C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ").C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"),end="\n\n",)print(nc.this_is_a_list)checkit=(nc.C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\blaaaaaaaaaaaaaaaaaaaaaaaa").C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ").C_Windows_notepad_exe_method_with_more_kwargs_as_args_last("f:\\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"))print(f'nc is checkit? ->{ncischeckit}')#output:NewClass.delete_files(self,file='C:\\Windows\\notepad.exe')Filewillbedeleted:C:\Windows\notepad.exeNoneNewClass.delete_files(self,file='C:\\Windows\\notepad.exe')Filewillbedeleted:C:\Windows\notepad.exeNoneNewClass.copy_files(self,file='C:\\Windows\\notepad.exe',dst='C:\\Windows\\notepad555.exe')Filewillbecopied:C:\Windows\notepad.exeDest:C:\Windows\notepad555.exeNoneNewClass.create_files(self,file='C:\\Windows\\notepad.exe',folder='c:\\windows95')Filewillbecreated:C:\Windows\notepad.exec:\windows95NoneNewClass.upper(self,'C:\\Windows\\notepad.exe')C:\WINDOWS\NOTEPAD.EXENewClass.method_with_more_kwargs(self,file='C:\\Windows\\notepad.exe',folder='c:\\windows95')C:\Windows\notepad.exec:\windows95f:\blaaaaaaaaaaaaaaaaaaaaaaaaC:\Windows\notepad.exec:\windows95f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇC:\Windows\notepad.exec:\windows95f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<__main__.NewClassobjectat0x0000000005F199A0>NewClass.method_with_more_kwargs(self,'C:\\Windows\\notepad.exe','c:\\windows95')C:\Windows\notepad.exec:\windows95f:\blaaaaaaaaaaaaaaaaaaaaaaaa<__main__.NewClassobjectat0x0000000005F199A0>C:\Windows\notepad.exec:\windows95f:\blaaaaaaaaaaaaaaaaaaaaaaaaC:\Windows\notepad.exec:\windows95f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇC:\Windows\notepad.exec:\windows95f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<__main__.NewClassobjectat0x0000000005F199A0>NewClass.method_with_more_kwargs(self,'C:\\Windows\\notepad.exe','c:\\windows95')f:\blaaaaaaaaaaaaaaaaaaaaaaaaC:\Windows\notepad.exec:\windows95f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇC:\Windows\notepad.exec:\windows95f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXC:\Windows\notepad.exec:\windows95<__main__.NewClassobjectat0x0000000005F199A0>f:\blaaaaaaaaaaaaaaaaaaaaaaaaC:\Windows\notepad.exec:\windows95f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇC:\Windows\notepad.exec:\windows95f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXC:\Windows\notepad.exec:\windows95<__main__.NewClassobjectat0x0000000005F199A0>[55,3,3,1,4,43]f:\blaaaaaaaaaaaaaaaaaaaaaaaaC:\Windows\notepad.exec:\windows95f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇC:\Windows\notepad.exec:\windows95f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXC:\Windows\notepad.exec:\windows95ncischeckit?->True