1. Interactive Python inside NppExec
Running "python -?" gives the following help information, in particular:
The text in italic 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++.
2. 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
or
# -*- 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 env_set PYTHONIOENCODING=utf-8 python my_program.py
3. Running Python scripts using wxPython
[the text below has been originally posted by cioma in NppExec's forum]
[ cioma: ]
I use NPP as an IDE for Python. And I use NppExec to run scripts directly from NPP, highlight script syntax and runtime errors (if any) and link errors to a line of code.
Some time ago I started using wxPython GUI library and faced problems with running such scripts from within NppExec.
If I run this (in NppExec prompt):
python -t -B -u "$(FULL_CURRENT_PATH)"...then GUI part of wxPython is not shown. I guess the reason is that wxPython requires a "real" console buffer and NppExec doesn't provide that.
If I just run script over NPP "Run" dialog (no NppExec) then GUI is shown but if there are errors there is no way to easily relate them to line of code in NPP.
So I found this solution to work:
1. When creating wxPython application in the script make sure it's STDOUT is not redirected:
app = App(redirect=False)2. Run in NppExec:
cmd /C python -t -B -u "$(FULL_CURRENT_PATH)"Voila! We have both wxPython GUI running and its STDOUT redirected to NppExec.
[ DV: ]
Just one thing. For more details regarding runtime errors parsing (keyword: Highlight filters), refer to [4.7.4] and "help con_filter".