diff options
Diffstat (limited to 'modules/language/python/module')
-rw-r--r-- | modules/language/python/module/python.scm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/modules/language/python/module/python.scm b/modules/language/python/module/python.scm index 296a304..2c08f55 100644 --- a/modules/language/python/module/python.scm +++ b/modules/language/python/module/python.scm @@ -42,7 +42,7 @@ set all any bin callable reversed chr classmethod staticmethod divmod enumerate filter format - getattr hasattr hex isinstance + getattr hasattr hex isinstance issubclass iter map sum id input oct ord pow super sorted zip)) @@ -108,13 +108,20 @@ (define (hasattr a b) (let ((r (refq a (symbol->string b) miss))) (not (eq? r miss)))) - -(define (isinstance o cl) - (if (pair? cl) - (or - (isinstance o (car cl)) - (isinstance o (cdr cl))) - (is-a? o cl))) + +(define-method (issubclass (sub <p>) (cls <p>)) + (aif it (ref cl '__subclasscheck__) + (it sub) + (is-a? (ref sub '__goops__) (ref cls '__goops__)))) + +(define-method (isinstance (o <p>) (cl <p>)) + (aif it (ref cl '__instancecheck__) + (it o) + (if (pair? cl) + (or + (isinstance o (car cl)) + (isinstance o (cdr cl))) + (is-a? (ref (ref o '__class__) '__goops__) cl))) (define iter (case-lambda |