TypeError: 'encoding' is an invalid keyword argument for this function
+1 to The Unfun Cat for a correct answer regarding Linux etc.
For Windows users, however, calling 'Python3' generally won't work. But if you've installed Python 3.3 (or if you've downloaded and installed Python Launcher for Windows), you can type:
C:\scr>py -3 yourfile.py
Actually, this launcher also supports shebang syntax, so adding the following first line to your script's file will work fairly cross-platform (the /usr/bin is ignored on Windows):
#! /usr/bin/python3
After doing that, assuming that windows\py.exe is the default handler for .py files, you can just type:
C:\scr>yourfile.py
And if ".PY" is in your PATHEXT environment variable, you can just type:
C:\scr>yourfile
More info:
http://docs.python.org/3/whatsnew/3.3.html
http://www.python.org/dev/peps/pep-0397/
using io.open()
instead of open
removed this error for me
eg:
import io
with io.open('gaeilge_flashcard_mode.txt','r', encoding='utf8') as file:
for line in file:
line1 = line.rstrip().split("=")
key = line1[0]
trans = line1[1]
PoS = line1[2]
Flashcards(key, trans, PoS)
reference: see this answer
The terminal you are trying to run this on probably uses Python 2.x as standard.
Try using the command "Python3" specifically in the terminal:
$ Python3 yourfile.py
(Tested and confirmed that 2.7 will give that error and that Python3 handles it just fine.)