Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiProxPy

A small python-package that allows you to "group" calls to objects.

The cool part is that the resulting "MultiProxy"-object can be used like the referenced objects:

from MultiProxPy import group_objects

list1 = [3,1,2]
list2 = [5,2]
list3 = [7,8,9]

list_proxy = group_objects(list1, list2, list3)

list_proxy.sort()   # Sorts all lists
list_proxy.append(15)   # Appends 15 to all lists
list_proxy[0] = -1  # Sets the first elemet to 0 for all lists

print(list1, list2, list3)

The grouping is very abstract and should work with any type of object.

The best part is that your IDE will treat the proxy-object like one of the contained objects. It will suggest methods/attributes bound to that class:
img.png
(The image might not show on PyPi. Here is the link: https://github.com/CheesecakeTV/MultiProxPy/blob/main/assets/images/SuggestionsOnProxyObject.png)

Other examples can be found in the github-repository: https://github.com/CheesecakeTV/MultiProxPy

Limitations

There are a few downsides you should be aware of.

  1. Any return-value on proxy-calls will be lost
  2. Simmilarely, math operations like additions don't work for the proxy. However, inline-operations do, e.g.: list_proxy += [5]
  3. The proxy can't fool isinstance, e.g.: isinstance(list_proxy, list) will return False
  4. Objects inside the proxy should have the same type, or a derived one. This is only a suggestion. If you are careful enough, you can mix different types

About

Python-package to combine multiple objects into one

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages