I want to define a dictionary inside a function. How I can define that dictionary only one time and on the function creation time. I'm trying to prevent dictionary creation on each function call. currently I define a global dictionary and use that inside the function, but is there another solution?
media_types = {
1: 'New Video',
2: 'New Image',
3: 'New File',
}
def get_media_type(t):
return media_types.get(t, None)