Skip to main content

No project description provided

Project description

# privatebroker

PrivateBroker (beta) is a module for encapsulation.

It allows you to hide methods of classes that are undesirable in the implementation of child elements. Private methods become unavailable in instances of classes and classes of heirs.

Private methods are kept in the "broker", which allows you to access the private method if necessary.

## Installation

Use the package manager [pip]( to install foobar.

pip install privatebroker

## Usage

the privateclass decorator accepts a class whose specific methods must be hidden. the decorator privatemethod accepts the method and puts it in the broker.

The broker returns the necessary function (attribute of the private method) by taking two arguments: the class (from example A (!! not self !!)) and the name of the method (the string is required).

To get the result of a private method, you need to refer to the attribute of the private method and pass it the arguments expected by the private method.


from privatebroker import privateclass, privatemethod

class A(object):

def __init__(self, *args, **kwargs):
self.some_one = {}

def a_private2(self):

def a_private(self, key, value):
self.some_one[key] = value

def test(self, x, y):
private =, 'a_private') # call to private
return private(self, x, y)

def a_public(self):
return self.some_one

#a = A()
#print(a.a_private()) - > Error

class B(A):

def b_private(self):
return 'Я могу быть только у объекта B'

def b_public(self):
self.test('a', 11)
return self.some_one

b = B()

## Contributing

This is the first test version and so far the expediency of using this module is questionable!
Traction requests are welcome. For major changes, please first open the question to discuss
what you would like to change.

Please remember to update the tests as needed.

## License

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

privatebroker-0.0.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page