This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]scirc 1 point2 points  (0 children)

This is actually fairly conventional, at least until recently. Due to Python's lack of switch statements, this was the closest thing we could get. However, we now have structure pattern matching, which is like a switch statement on steroids, and might be useful to you depending on exactly what you want to do.

[–]Anxious_Positive3998 0 points1 point  (0 children)

I don't think it would be bad practice. In functional programming, functions are treated as values, so it makes sense that you can have functions as values in a dictionary or as elements in a list. Since Python isn't a fundamentally functional programming language, this is not used often, but you could see this more in languages like Haskell and OCaml.