FAQ
You don't have to write anything so complicated to see that Python
doesn't work the way you want it to work. For instance,

def add_one(x):
x = x + 1

x = 1
add_one(x)
print x # prints 1, not 2

If you really want to write 'setFunction', you'll have to do it
something like this:

def setFunction(self, funcname, tofunc):
setattr(self, funcname, tofunc)
# OR
# self.__dict__[funame] = tofunc

and call it like this:
a.setFunction('myPrint', self.newPrint)

This is really a very odd thing to do, though...

Jeff

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 8 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJan 8, '03 at 8:34p
activeJan 10, '03 at 5:41a
posts8
users5
websitepython.org

People

Translate

site design / logo © 2023 Grokbase