Skip to content

Instantly share code, notes, and snippets.

View andrewgodwin's full-sized avatar

Andrew Godwin andrewgodwin

View GitHub Profile
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
class X:
@staticmethod
def y(self):
return 3
z = [y]
>>> X.y
<function X.y at 0x7fc5e5ca90d0>
from __future__ import unicode_literals
from django.core import validators
from django.db import models, migrations
from django.utils import timezone
class Migration(migrations.Migration):
dependencies = [
@andrewgodwin
andrewgodwin / test.py
Last active August 29, 2015 14:01
Function Membership Introspection
class MyClass(object):
def a(self):
pass
b = [a]
# Get the reference to a from the list
a = MyClass.b[0]
# How do I get the class a was defined on? Is it even possible?
# On Python 3, I can use __qualname__. This isn't around on Python 2.