1 (define-module (language python module python
)
2 #:use-module
(oop goops
)
3 #:use-module
((oop pf-objects
) #:select
4 (<p
> class-method static-method refq
))
5 #:use-module
(language python exceptions
)
6 #:use-module
(language python for
)
7 #:use-module
(language python try
)
8 #:use-module
(language python yield
)
9 #:use-module
(language python list
)
10 #:use-module
(language python dict
)
11 #:use-module
(language python set
)
12 #:use-module
(language python compile
)
13 #:use-module
(language python string
)
14 #:use-module
(language python set
)
15 #:use-module
(language python number
)
16 #:use-module
(language python dir
)
17 #:use-module
(language python hash
)
20 #:re-export
(Exception StopIteration send sendException next
21 GeneratorExit sendClose RuntimeError
23 #:export
(print repr complex float int round
24 set all any bin callable
25 chr classmethod staticmethod
26 divmod enumerate filter format
27 getattr hasattr hash hex isinstance
33 ((x) (format #t
"~s~%" x
))
34 (l (format #t
"~s~%" l
))))
36 (define (repr x
) (format #f
"~a" x
))
39 (define string pystring
)
40 (define complex py-complex
)
41 (define float py-float
)
43 (define round py-round
)
48 (define divmod py-divmod
)
49 (define format py-format
)
53 (define-method (callable x
) #f
)
54 (define-method (callable (x <procedure
> )) #t
)
55 (define-method (callable (x <procedure-class
> )) #t
)
56 (define-method (callable (x <applicable
> )) #t
)
57 (define-method (callable (x <primitive-generic
>)) #t
)
58 (define-method (callable (x <p
>))
61 (define chr integer-
>char
)
63 (define classmethod class-method
)
64 (define staticmethod static-method
)
67 (make-generator enumerate
69 (for ((x : l
)) ((i 0))
74 (make-generator enumerate
80 (define miss
(list 'miss
))
82 (define* (getattr a b
#:optional
(k miss
))
83 (let ((r (ref a
(symbol->string b
) k
)))
85 (raise AttributeError
"object/class ~a is missing attribute ~a" a b
)
89 (let ((r (ref a
(symbol->string b
) k
)))
92 (define (isinstance o cl
)
95 (isinstance o
(car cl
))
96 (isinstance o
(cdr cl
)))
101 ((o) (aif it
(wrap-in o
)
103 (aif get
(ref o
'__getitem__
)
109 (raise TypeError
"not iterable" o
))))
125 (with-syntax (((x ...
) (generate-temporaries #'(a ...
))))
126 #'(make-generator map
128 (for ((x : a
) ...
) () (yield (f x ...
))))))))))