Is it possible to define global variables in a function in Python

function, global-variables, python

Solution

Yes, but why?

def a():
    globals()['something'] = 'bob'

Problem

How do I declare a global variable in a function in Python? That is, so that it doesn't have to be declared before but can be used outside of the function.

Original source