Changeset 33407 in project


Ignore:
Timestamp:
06/11/16 23:44:22 (3 years ago)
Author:
Ivan Raikov
Message:

updated pyffi doc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/pyffi

    r26328 r33407  
    112112
    113113
    114 <macro>(define-pymethod NAME [SCHEME-NAME])</macro>
     114<macro>(define-pymethod NAME [SCHEME-NAME: NAME] [KW: NAME-LIST])</macro>
    115115
    116116Defines an accessor for the Python method {{NAME}}. The optional
    117 argument {{SCHEME-NAME}} is an alternate name for the Scheme
    118 procedure. The accessor is a procedure of the form {{LAMBDA OBJ ARG1
    119 ...}} that takes in a Python object {{OBJ}} and invokes the method
    120 {{NAME}} contained in that object, with the supplied arguments, which
    121 must be either Scheme values of types listed in the type conversion
    122 table above, or pointers to Python values. If the object has no such
    123 method, #f is returned.
     117keyword argument {{SCHEME-NAME}} is an alternate name for the Scheme
     118procedure. The optional keyword argument {{KW}} is a list of keyword
     119argument names for the Python method. The accessor is a procedure of
     120the form {{LAMBDA OBJ ARG1 ...}} that takes in a Python object {{OBJ}}
     121and invokes the method {{NAME}} contained in that object, with the
     122supplied arguments, which must be either Scheme values of types listed
     123in the type conversion table above, or pointers to Python values. If
     124the object has no such method, #f is returned.
    124125
    125126
     
    127128== Examples
    128129
    129 
     130<enscript highlight="scheme">
     131(import chicken)
     132(require-extension pyffi)
     133
     134(py-start)
     135
     136(py-import "h5py")
     137(py-import "numpy")
     138
     139
     140(define-pyfun "h5py.File" name mode)
     141(define-pymethod "close") ;; File
     142(define-pymethod "create_dataset" kw: (dtype)) ;; File
     143
     144(define-pyslot "shape")
     145(define-pyslot "dtype")
     146(define-pyslot "name")
     147
     148(define f (h5py.File "mytestfile.hdf5" "w"))
     149
     150(define dset (create_dataset f "mydataset"  (vector 100) dtype: "i"))
     151
     152(print (py-object-from (name dset)))
     153(print (py-object-from (shape dset)))
     154(print (py-object-type (dtype dset)))
     155
     156(close f)
     157</enscript>
     158
     159<enscript highlight="scheme">
    130160 ;;
    131161 ;; Python-UNO example from pyffi.lisp by Dmitri Hrapof.
     
    170200 
    171201 (message-uno "Hello, world!")
    172 
     202</enscript>
    173203
    174204== About this egg
     
    181211=== Version history
    182212
     213; 3.3 :  added support for keyword arguments in method definitions
    183214; 3.0 :  using [[bind]] instead of [[easyffi]]
    184215; 2.18 : setup script updated for Python 2.7 (thanks to Mario Domenech Goulart)
     
    194225
    195226
    196  Copyright 2007-2012 Ivan Raikov. Based on pyffi.lisp by Dmitri Hrapof.
     227 Copyright 2007-2016 Ivan Raikov. Based on pyffi.lisp by Dmitri Hrapof.
    197228 
    198229 This program is free software: you can redistribute it and/or modify
Note: See TracChangeset for help on using the changeset viewer.