Is there a way to set an objects id or memory position? Ultimately I'm trying to change function "a" to function "b" while still preserving any saved reference to function "a"
ihatehippies
11
Junior Poster
Recommended Answers
Jump to PostI think you may be over-thinking. This works as expected:
def fun_a(): return "I am function a" def fun_b(): return "I'm b" s = { 'a': fun_a, 'b': fun_b} print("s['a'](): %s"%s['a']()) print("s['b'](): %s"%s['b']()) keep_fun = fun_a fun_a = fun_b print("After fun_a = fun_b") print("s['a'](): %s"%s['a']()) print("s['b'](): %s"%s['b']()) …
Jump to PostI think you are out of luck doing it directly because wxPython is keeping the reference. Can you do it with a function wrapper? For instance, just off the top of my head:
class Dispatcher: def __init__(self, aFunction): self.function = aFunction def __call__(*args): return self.function(*args) # Now …
All 7 Replies
griswolf
304
Veteran Poster
ihatehippies
11
Junior Poster
griswolf
304
Veteran Poster
ihatehippies
11
Junior Poster
griswolf
304
Veteran Poster
ihatehippies
11
Junior Poster
ihatehippies
11
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.