TypeError: cannot concatenate 'str' and 'builtin_function_or_method' objects in python
Question: Please I am beginner in python coding.This is my code and am not able to
resolve the error . Can some one suggest me what is the prob in code actually.
thanks in advance.

    
    
    import urllib2
    username = '<YOUR USERNAME>'
    password = '<YOUR PASSWORD>'
    format = 'json' # json or xml
    filename = 'archive.json' # filename of the archive
    tweets = 164 # number of tweets
    pages = (int(float(tweets)/float(80)))+1
    auth = urllib2.HTTPPasswordMgrWithDefaultRealm()
    auth.add_password(None, 'http://twitter.com/account/', username, password)
    authHandler = urllib2.HTTPBasicAuthHandler(auth)
    opener = urllib2.build_opener(authHandler)
    urllib2.install_opener(opener) 
    i = 1
    response = ''
    print 'Downloading tweets. Note that this may take some time'
    while i <= pages:
        request = urllib2.Request('http://twitter.com/statuses/user_timeline/account.' \
        + format + '?page=' + str(i))
        response = response + urllib2.urlopen(request).read()
        i = i + 1
    handle = open(filename,"w")
    handle.write(response)
    handle.close()
    print 'Archived ' + str(tweets) + ' of ' + username + \
    '\'s tweets to ' + filename
    

ERROR is like this below:

    
    
    **Traceback (most recent call last):
      File "<pyshell#14>", line 3, in <module>
        + format + '?page=' + str(i))
    TypeError: cannot concatenate 'str' and 'builtin_function_or_method' objects**
    


Answer: `format` is a built-in function. The error you quote is exactly what you get
if you try to use `+` with the built-in `format` and a string.

Your earlier assignment `format = 'json'` should have shadowed the built-in
function. But your error trace indicates that you're running this from some
sort of shell, and not actually executing the code as you have posted it. So
without knowing what exactly is executing, my guess is your assignment to
`format` isn't in effect, for whatever reason.

