Skip to main content

Add methods and properties to an existing object

$pip install add-methods-and-properties-to-existing-object

from add_methods_and_properties_to_existing_object import AddMethodsAndProperties



class NewClass(AddMethodsAndProperties): #inherit from AddMethodsAndProperties to add the method add_methods

    def __init__(self):

        self.bubu = 5



    def _delete_files(self, file): #some random methods 

        print(f"File will be deleted: {file}")



    def delete_files(self, file):

        self._delete_files(file)



    def _copy_files(self, file, dst):

        print(f"File will be copied: {file} Dest: {dst}")



    def copy_files(self, file, dst):

        self._copy_files(file, dst)



    def _create_files(self, file, folder):

        print(f"File will be created: {file} {folder}")



    def create_files(self, file, folder):

        self._create_files(file, folder)



    def method_with_more_kwargs(self, file, folder, one_more):

        print(file, folder, one_more)

        return self





nc = 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? -> {nc is checkit}')





#output:





NewClass.delete_files(self, file='C:\\Windows\\notepad.exe')

File will be deleted: C:\Windows\notepad.exe

None





NewClass.delete_files(self, file='C:\\Windows\\notepad.exe')

File will be deleted: C:\Windows\notepad.exe

None





NewClass.copy_files(self, file='C:\\Windows\\notepad.exe', dst='C:\\Windows\\notepad555.exe')

File will be copied: C:\Windows\notepad.exe Dest: C:\Windows\notepad555.exe

None





NewClass.create_files(self, file='C:\\Windows\\notepad.exe', folder='c:\\windows95')

File will be created: C:\Windows\notepad.exe c:\windows95

None





NewClass.upper(self, 'C:\\Windows\\notepad.exe')

C:\WINDOWS\NOTEPAD.EXE





NewClass.method_with_more_kwargs(self, file='C:\\Windows\\notepad.exe', folder='c:\\windows95')

C:\Windows\notepad.exe c:\windows95 f:\blaaaaaaaaaaaaaaaaaaaaaaaa

C:\Windows\notepad.exe c:\windows95 f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ

C:\Windows\notepad.exe c:\windows95 f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

<__main__.NewClass object at 0x0000000005F199A0>





NewClass.method_with_more_kwargs(self, 'C:\\Windows\\notepad.exe', 'c:\\windows95')

C:\Windows\notepad.exe c:\windows95 f:\blaaaaaaaaaaaaaaaaaaaaaaaa

<__main__.NewClass object at 0x0000000005F199A0>





C:\Windows\notepad.exe c:\windows95 f:\blaaaaaaaaaaaaaaaaaaaaaaaa

C:\Windows\notepad.exe c:\windows95 f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ

C:\Windows\notepad.exe c:\windows95 f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

<__main__.NewClass object at 0x0000000005F199A0>





NewClass.method_with_more_kwargs(self, 'C:\\Windows\\notepad.exe', 'c:\\windows95')

f:\blaaaaaaaaaaaaaaaaaaaaaaaa C:\Windows\notepad.exe c:\windows95

f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ C:\Windows\notepad.exe c:\windows95

f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX C:\Windows\notepad.exe c:\windows95

<__main__.NewClass object at 0x0000000005F199A0>





f:\blaaaaaaaaaaaaaaaaaaaaaaaa C:\Windows\notepad.exe c:\windows95

f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ C:\Windows\notepad.exe c:\windows95

f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX C:\Windows\notepad.exe c:\windows95

<__main__.NewClass object at 0x0000000005F199A0>





[55, 3, 3, 1, 4, 43]





f:\blaaaaaaaaaaaaaaaaaaaaaaaa C:\Windows\notepad.exe c:\windows95

f:\ASJVASDFASÇDFJASÇDJFÇASWFJASÇ C:\Windows\notepad.exe c:\windows95

f:\XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX C:\Windows\notepad.exe c:\windows95





nc is checkit? -> True

Metadata

Release files for add-methods-and-properties-to-existing-object 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for add-methods-and-properties-to-existing-object 0.10
File Size Uploaded Provenance Actions
add_methods_and_properties_to_existing_object-0.10.tar.gz 6.4 kB Without provenance Details for add_methods_and_properties_to_existing_object-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for add-methods-and-properties-to-existing-object 0.10
File Interpreter ABI Platform Actions
add_methods_and_properties_to_existing_object-0.10-py3-none-any.whl Python 3 none any Details for add_methods_and_properties_to_existing_object-0.10-py3-none-any.whl

Total release size: 14.1 kB

Release files / add_methods_and_properties_to_existing_object-0.10.tar.gz

Download URL add_methods_and_properties_to_existing_object-0.10.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f6c15558e5e34ca59ed3aec2ae2b536d0fcc4c609fd0df00dc7c72bc881b0266
BLAKE2b-256 checksum
How to use checksums
7d494d7e9da9c0d3aa128812316cde1d8535339c19dd91f059f20119f6fb60f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / add_methods_and_properties_to_existing_object-0.10-py3-none-any.whl

Download URL add_methods_and_properties_to_existing_object-0.10-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
72d68eab57f0da530c51be7d25c874f25f4495adeeffc836411f92c6bb283d2c
BLAKE2b-256 checksum
How to use checksums
3f54d95442491fe215fcbd13b5d90d8524ec21f505c551bc237a575cf84fc233
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for add-methods-and-properties-to-existing-object 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page