On Thu, 16 Jun 2016, 23:31 Harrison Chudleigh, < harrison.chudlei...@education.nsw.gov.au> wrote:
> Sorry! I was trying to indent a line and accidentally sent only half of the > message. > It would be helpful if your reply was actually a reply to your previous message, to enable us to follow the thread of the conversation. As I was saying, I changed the line and reran the program. However, this > produced another group of error messages. One was - > >From what, to what? Just showing us stacktraces means we have to guess at the problem. File > > "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py", > line 438, in open > encoding, lines = detect_encoding(buffer.readline) > File > > "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tokenize.py", > line 409, in detect_encoding > if first.startswith('BOM_UTF8'): > TypeError: startswith first arg must be bytes or a tuple of bytes, not str. > So, first the interpreter says startswith() takes strings, now it says it > takes bytes? What should the module be doing? > The reason you're getting seemingly contradictory error messages is that `.startswith()` is a method which belongs to the `first` object, and that object is a different type between the first and the second time it's called. Both the `bytes` and `str` types have a `startswith` method, but each one (understandably) only accepts an argument of the same type. Without actually seeing your code I can't guess what the cause of that is, but perhaps you need to decode a `bytes` object to a `str` or encode the other way around. -- https://mail.python.org/mailman/listinfo/python-list