I'm studying python right now. And i have a simple example program. It asks questions to user and recives answers. After it the program show user scores.
When i save this script and run it from explorer - it works as it need to work - right way. But if i run it from nppexec with next parametrs - c:\Python25\python.exe "$(FULL_CURRENT_PATH)" - it's at first wait me to input all keys one after one (without any indications), and after then type all dialogs (questions) without prompting me.
Also, i use other versions of python (third branch) - and it works great with the same parametrs of nppexec (c:\Python30\python.exe "$(FULL_CURRENT_PATH)")
Can you help me?
I use nppexec ver 0.3.2 and NPP 5.3.1 unicode
Running "python -?" gives the following help information, in particular:
-i : inspect interactively after running script, (also PYTHONINSPECT=x)
and force prompts, even if stdin does not appear to be a terminal
-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
see man page for details on internal buffering relating to '-u'
The text in bold exactly refers to what is stated in NppExec's Manual, sections 1.3 and 3.1 by "NppExec is not a console emulator".
So, by running "python -i -u" in NppExec's Console, you get the interactive Python inside Notepad++.
Some words about Python and UTF-8.
If your python's program contains some non-ASCII characters, you can get the following error from Python: "SyntaxError: Non-ASCII character".
To be able to represent such non-ASCII characters correctly on any system, such source file should be saved as UTF-8 (either without BOM or with BOM). Though the error mentioned above still remains. To avoid this error, acccording to http://www.python.org/dev/peps/pep-0263/ , you just need to specify
# -*- coding: utf-8 -*-
at the beginning of your python's program.
Another thing is to output something to console as UTF-8.
In this case, you can get something similar from Python: "UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-2: character maps to <undefined>".
To fix this last one, it's enough to specify the environment variable PYTHONIOENCODING by setting it to "utf-8". I.e.
// within NppExec