Skip to content

Instantly share code, notes, and snippets.

View namper's full-sized avatar
🔁
Reindexing

Mishiko (მიშო) namper

🔁
Reindexing
  • Tbilisi, Georgia (საქართველო)
  • 15:49 (UTC +04:00)
View GitHub Profile
@namper
namper / private.py
Created April 21, 2021 20:40 — forked from latsa/private.py
Python @Private decorator
import sys, functools
def private(member):
@functools.wraps(member)
def wrapper(*function_args):
myself = member.__name__
caller = sys._getframe(1).f_code.co_name
if (not caller in dir(function_args[0]) and not caller is myself):
raise Exception("%s called by %s is private"%(myself,caller))
return member(*function_args)