> Now the problem is another one... And NOT related to PySide, it's pure > Python. The problem is in the 'get_date()' func > (http://pastebin.com/mPhJcXmF) - I get all the text from bankofcanada site > but when I reach 'line.strip()' I get an error, "'int' object has no > attribute 'strip'".
You've got a type error. Let's analyze why. What are the types we're dealing with? Let's see. In line 4 of the program: fh = urllib.request.urlopen("http://www.bankofcanada.ca/en/markets/csv/exchange_eng.csv").read() urlopen() gives us a response object, according to: https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen What is the return type of read()? https://docs.python.org/3/library/http.client.html#http.client.HTTPResponse.read It sounds like it's returning a "bytes". But what is a "bytes"? https://docs.python.org/3/library/stdtypes.html#bytes Reading... ah, there's a section in the documentation on bytes that is relevant: """While bytes literals and representations are based on ASCII text, bytes objects actually behave like immutable sequences of integers""" Why is this fact relevant? Because the loop here is trying to iterate over the individual elements in fh: for line in fh: And from reading the documentation, those elements are the individual byte integer values. And so the "line" in line 6: for line in fh: is not truly representing a line of text: it's representing a single numeric byte in your input. So that's the origin of the error. Correct the code by using bytes.split(). https://docs.python.org/3/library/stdtypes.html#bytes.split So the loop really should be: for line in fh.split("\n"): ... _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor