Question

I'm current writing a short bit of code that will compare an etag for a web server page in a saved document to the etag on the server. If they are different, the code will indicate this. My code is below:-

import httplib

def currentTag():
    f = open('C:/Users/ME/Desktop/document.txt')
    e = f.readline()
    newTag(e)

def newTag(old_etag):
    c = httplib.HTTPConnection('standards.ieee.org')
    c.request('HEAD', '/develop/regauth/oui/oui.txt')
    r = c.getresponse()
    current_etag = r.getheader('etag').replace('"', '')
    compareTag(old_etag, current_etag)

def compareTag(old_etag, current_etag):
    if old_etag == current_etag:
        print "the same"
    else:
        print "different"

if __name__ == '__main__':
    currentTag()

Now, reviewing my code, there is actually no reason to pass 'etag' from the currentTag() method to the newTag() method given that the pre-existing etag is not processed in newTag(). Nonetheless, if I don't do this, how can I pass two different values to compareTag(). So for example, when defining compareTag(), how can I pass 'etag' from the currentTag() method and 'current_etag' from the newTag() method?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top