Skip to content

Instantly share code, notes, and snippets.

View pauricthelodger's full-sized avatar

Padraic Harley pauricthelodger

View GitHub Profile
@pauricthelodger
pauricthelodger / sometimes.py
Created April 28, 2025 23:11 — forked from judy2k/sometimes.py
A descriptor that wraps a method that can be called on a class or an instance.
from functools import wraps
class SometimesClassmethod:
def __init__(self, wrapped_function):
self._wrapped = wrapped_function
def __get__(self, instance, owner=None):
if instance is None:
return self._class_call(owner)