Polymorphing - how?
Jaros³aw Zabie³³o (delete .PL)
webmaster at apologetyka.com.pl
Wed May 1 16:39:24 EDT 2002
I would like to execute functions which names will be changed during
runtime. The following approach does not work. :-(
def First(s):
print "myFun1: %s" % s
def Second(s)
print "myFun2: %s" % s
name = 'First'
name('blah') # It doesn't work. :-(
# TypeError: 'str' object is not callable
name = 'Second'
name('blah') # Like above.
The following code in PHP does work:
<?php
function First($s) { print "myFun1: $s"; }
function Second($s) { print "myFun2: $s"; }
$name = 'First';
$name('blah'); # It works.
print "\n";
$name = 'Second'; # It works.
$name('blah');
?>
Is it possible for Python?
--
Jarosław Zabiełło (UIN: 6712522)
URL: http://3585753410/~zbiru
More information about the Python-list
mailing list