Full script: https://gist.github.com/4476526
The specific code in question is
# Cloud Files username & API key
username = ''
key = ''
# Source and destination container names
originContainerName = ''
targetContainerName = ''
...
def cloudConnect():
global originContainer
global targetContainer
global connection
print "Creating connection"
connection = cloudfiles.get_connection(username,key,servicenet=True)
print "-- [DONE]"
print "Accessing containers"
originContainer = connection.create_container(originContainerName)
targetContainer = connection.create_container(targetContainerName)
print "-- [DONE]"
return
The script works perfectly fine, however I've read in multiple places that global variables should be used with hesitation and that there is almost always a better way to do the same thing without them. Is this true? And if so, how exactly should I fix this script? To me it seems much easier just to use global connection and container variables instead of passing those objects around as arguments in multiple functions.