Skip to content

About

Use private, protected class method in Python!!!

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

Access Modify

Use private, protected class methods in Python!

Download

pip install access-modify

Example

from access_modify import *


@access
class Test:
    # Test.a can be used by Test class methods.
    @private
    def a(self): return 1
    
    # Test.b can be used by Test class, or inherited class methods.
    @protected
    def b(self): return self.a()+1

class Inherited(Test):
    @public
    def c(self): return self.b()+1

r = Test()
w = Inherited()
print(r.a()) # raise AccessException
print(r.b()) # raise AccessException
print(w.c()) # 3

About

Use private, protected class method in Python!!!

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages