Connecting Tech Pros Worldwide Help | Site Map

Python in Notepad++

Newbie
 
Join Date: Aug 2007
Posts: 1
#1: Aug 26 '07
Hi Everybody,
I am new to Python and also new to Notepad++. Can any one help to code my first python program in Notepad++. I am already doing it in python interpretor, but now i was to do in Notepad++. I have already downloaded Notepad++, but still not able to run any python program in it.
I request any of you to help me start in NOtepad++ with python.
Thanks
bartonc's Avatar
Moderator
 
Join Date: Sep 2006
Location: Minden, Nevada, USA
Posts: 6,400
#2: Aug 26 '07

re: Python in Notepad++


Quote:

Originally Posted by sanjayhpatel2000

Hi Everybody,
I am new to Python and also new to Notepad++. Can any one help to code my first python program in Notepad++. I am already doing it in python interpretor, but now i was to do in Notepad++. I have already downloaded Notepad++, but still not able to run any python program in it.
I request any of you to help me start in NOtepad++ with python.
Thanks

The answer to that question is in reply #7 of this thread, but I think that you will find the IDLE is sufficient for your needs for the time being and has much of the things that you will have to work on to get Notepad++ working built in. The aforementioned thread also discusses other IDE options.
Newbie
 
Join Date: Feb 2008
Posts: 1
#3: Feb 2 '08

re: Python in Notepad++


There is a simple way to do it.
In the Run menu, you can see options like "Lunch in firefox" and more.
These options are written in a file called shortcuts.xml, located in the folder where you installed NP++.
Open this file, and inside <UserDefinedCommands> you'll find this row:
Expand|Select|Wrap|Line Numbers
  1.  <Command name="launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;$(FULL_CURRENT_PATH)&quot;</Command>
All you need to do is copy this line and change some things. Then you'll have something like this:
Expand|Select|Wrap|Line Numbers
  1. <Command name="Run with Python" Ctrl="no" Alt="no" Shift="yes" Key="112">python &quot;$(FULL_CURRENT_PATH)&quot;</Command>
(I chose Shift+F1, but you can choose any keys you like.)

Reopen NP++, and now it's easy and nice to run any python file strait from the editor.
More information on things like this in NP++: http://notepad-plus.wiki.sourceforge.net/Run
Newbie
 
Join Date: Oct 2009
Posts: 1
#4: Oct 5 '09

re: Python in Notepad++


thanks weightlessness for the direction, you can also try this
Expand|Select|Wrap|Line Numbers
  1. <Command name="python+arg" Ctrl="yes" Alt="no" Shift="no" Key="122">cmd /K &quot;$(FULL_CURRENT_PATH)&quot; $(CURRENT_WORD)</Command>
here i call a command line (with th /k switch so it doesn't close after execution or errors), i also add the CURRENT_WORD for if i want to add arguments (i keep some for debugging as comments in the code).

note i have python.exe in my PATH so i can call the .py file as is.

there is no easy way to edit the command once you enter it, i open %USERPROFILE%\Application Data\Notepad++\shortcuts.xml in palin notepad (keep NP++ closed while editing) and play around with the command.
Newbie
 
Join Date: Nov 2009
Posts: 2
#5: 4 Days Ago

re: Python in Notepad++


Or you could setup NppExec
Go to Plugins -> NppExec -> Execute (default F6, you can change this)
Type in the window:
C:\Python31\python.exe "$(FULL_CURRENT_PATH)"

Make sure the path to python.exe actually points to where your python.exe is :)

Click Save and save it whichever name you want it to be saved as.
And you're done. Switch between any files you like press F6 then Enter and you've compiled it!

Happy coding!
Reply