[PD-ot] Python method substitution

Frank Barknecht fbar at footils.org
Mon Apr 24 14:29:50 CEST 2006


Hallo,
Jamie Bullock hat gesagt: // Jamie Bullock wrote:

> Well this is extremely OT, but someone on this list might be willing to help...
> 
> Does anyone know of a way to use a variable in place of a method name Python. Something like:
> 
> foo = 'method'
> bar.foo
> 
> whereby bar.foo gets substituted by bar.method

pydoc getattr

See attached pyext patch, which uses this.

Ciao
-- 
 Frank Barknecht                 _ ______footils.org_ __goto10.org__
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pycall.py
Type: text/x-python
Size: 999 bytes
Desc: not available
Url : http://lists.puredata.info/pipermail/pd-ot/attachments/20060424/cd3a0b09/pycall.py
-------------- next part --------------
#N canvas 103 11 985 619 10;
#X obj 41 363 pyext pycall pymod os;
#X msg 41 331 reload;
#X msg 281 227 listdir /tmp;
#X msg 279 458 bogus;
#X msg 283 270 listdir .;
#X msg 280 324 __doc__;
#X msg 280 346 name;
#X msg 280 367 curdir;
#X msg 281 387 pardir;
#X msg 281 407 path;
#X msg 279 183 mkdir /tmp/python-test;
#X msg 280 205 rmdir /tmp/python-test;
#X msg 282 248 getcwd;
#X msg 278 160 getloadavg;
#X msg 276 138 getpid;
#X msg 275 116 getenv HOME;
#X msg 276 92 system gvim;
#X obj 520 175 pyext pycall pymod string;
#X msg 721 102 letters;
#X obj 524 450 print REGEX;
#X obj 520 200 print STRING;
#X obj 41 392 print OS;
#X msg 721 81 replace 12345 3 -THREE-;
#X msg 524 400 reload;
#X obj 524 425 pyext pycall pymod sre;
#X text 494 336 "[BS]" internally gets replaced by a backslash. Yes
\, I know it's a hack.;
#X msg 721 123 count iiiiiiiiiiiieeeehhh i;
#X msg 722 169 lower ABC;
#X msg 722 146 split X---Y---Z ---;
#X msg 673 388 sub [BS]d _NUM_ 12a3b4c5;
#X connect 0 0 21 0;
#X connect 1 0 0 0;
#X connect 2 0 0 1;
#X connect 3 0 0 1;
#X connect 4 0 0 1;
#X connect 5 0 0 1;
#X connect 6 0 0 1;
#X connect 7 0 0 1;
#X connect 8 0 0 1;
#X connect 9 0 0 1;
#X connect 10 0 0 1;
#X connect 11 0 0 1;
#X connect 12 0 0 1;
#X connect 13 0 0 1;
#X connect 14 0 0 1;
#X connect 15 0 0 1;
#X connect 16 0 0 1;
#X connect 17 0 20 0;
#X connect 18 0 17 1;
#X connect 22 0 17 1;
#X connect 23 0 24 0;
#X connect 24 0 19 0;
#X connect 26 0 17 1;
#X connect 27 0 17 1;
#X connect 28 0 17 1;
#X connect 29 0 24 1;


More information about the PD-ot mailing list