diff options
Diffstat (limited to 'modules/language/python/dir.scm')
-rw-r--r-- | modules/language/python/dir.scm | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/modules/language/python/dir.scm b/modules/language/python/dir.scm index da07642..e41e235 100644 --- a/modules/language/python/dir.scm +++ b/modules/language/python/dir.scm @@ -17,15 +17,15 @@ (define (chash-for-each f c) (let ((h (slot-ref c 'h))) - (if (is-a? c <pf>) - (let ((hh (make-hash-table))) - (vhash-fold - (lambda (k v s) - (when (not (hash-ref hh k)) - (hash-set! hh k #t) - (f k v)) - s) #f h)) - (hash-for-each f h)))) + (if (is-a? c <pf>) + (let ((hh (make-hash-table))) + (vhash-fold + (lambda (k v s) + (when (not (hash-ref hh k)) + (hash-set! hh k #t) + (f k v)) + s) #f h)) + (hash-for-each f h)))) (define (get-from-class c f) (let lp ((pl (ref c '__mro__))) @@ -38,20 +38,22 @@ (if (not (pyclass? o)) (aif it (ref o '__dir__) (it) - (aif it (ref o '__dict__) - (let ((l (pylist))) - (for ((k v : it)) () - (pylist-append! l k)) - (pylist-sort! l) - l) - (let* ((h (make-hash-table)) - (c (ref o '__class__)) - (l '()) - (f (lambda (k v) (set! l (cons k l))))) - (chash-for-each f o) - (get-from-class c f) - (hash-for-each (lambda (k v) (pylist-append! l k)) h) - (to-pylist (map symbol->string (sort l <)))))) + (begin + (let ((l1 (aif it (ref o '__dict__) + (let ((l (pylist))) + (for ((k v : it)) () + (pylist-append! l k)) + (pylist-sort! l) + l) + (pylist)))) + (let* ((h (make-hash-table)) + (c (ref o '__class__)) + (l '()) + (f (lambda (k v) (set! l (cons k l))))) + (chash-for-each f o) + (get-from-class c f) + (hash-for-each (lambda (k v) (pylist-append! l k)) h) + (+ (pylist (map symbol->string (sort l <))) l1))))) (let* ((h (make-hash-table)) (c o) (l '()) |