I was trying to come up with a dictionary of functions, but get it not to work.
bumsfeld
413
Nearly a Posting Virtuoso
Recommended Answers
Jump to PostSorry, mindreading is not my métier. Please gives us an example of your code and the error message you get.
Jump to PostYou mean something like this?
import re f = dict() f["compile"] = re.compile f["findall"] = re.findall f["match"] = re.match pattern = f["compile"]("[\\w]+")
This works for me.
Jump to PostG-Do did give you the hint, don't call the functions from the dictionary, just reference them. I took the liberty to play with your code a little ...
def add(a, b): return a + b def subtract(a, b): return a - b def multiply(a, b): return a …
All 9 Replies
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
G-Do
19
Junior Poster
bumsfeld
413
Nearly a Posting Virtuoso
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
bumsfeld
413
Nearly a Posting Virtuoso
vegaseat
1,735
DaniWeb's Hypocrite
Team Colleague
Kyss
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
Kyss
0
Newbie 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.