electronut / pp

Code for book Python Playground by Mahesh Venkitachalam (No Starch Press, USA)
564 stars 500 forks source link

Update playlist.py #4

Closed MortalCatalyst closed 8 years ago

MortalCatalyst commented 8 years ago

to avoid string error

Traceback (most recent call last):
  File "playlist.py", line 182, in <module>
    main()
  File "playlist.py", line 170, in main
    findCommonTracks(args.plFiles)
  File "playlist.py", line 50, in findCommonTracks
    f.write(s.encode("UTF-8"))
TypeError: must be str, not bytes

need to write 'wb' now instead of just 'w'

electronut commented 8 years ago

'wb' is for binary files, and only on windows. Could you please send me your OS and python versions? Thanks.

MortalCatalyst commented 8 years ago

Hi

Yes python 3.4.3 on 64 bit ubuntu 14.04.

Found the answer to the error here where they reference python 3 is now supposed to need it, the b

http://stackoverflow.com/a/5513856

electronut commented 8 years ago

Thanks for finding this. I've pulled your changes.