Skip to content

Instantly share code, notes, and snippets.

View namper's full-sized avatar
🔁
Reindexing

Mishiko (მიშო) namper

🔁
Reindexing
  • Tbilisi, Georgia (საქართველო)
  • 13:32 (UTC +04:00)
View GitHub Profile
@namper
namper / drf_switch_io_field.py
Last active September 21, 2022 17:58
DRF Switch IO Field
class SwitchIOField(Field):
def __init__(
self,
input_field: Field,
output_field: Field,
*args, **kwargs
):
# -- setting up input field
self.input_field = input_field
self.validators = input_field.validators
@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)