firefox add-on to grab python code handily?

C

CM

I encounter a fair number of small Python scripts online, and usually
try them out by copying them to the clipboard, pasting into Notepad,
saving them, and either running them directly or opening them in
IDLE.

And so I was wondering if anyone knew of an extension/add-on/script
for Firefox which would allow a way to do something like this:

user highlights Python code on a webpage
right clicks
selects a menu item, "Save as Python code"
FF pops up a filename dialog or popup for filename
(and, though I don't know if this is possible, runs Python code)

Not an important thing by any means, but it would be a nice
convenience.
I know there are similar add-ons in FF for grabbing highlighted text
and
saving, but they are not good, as they don't seem to preserve line
breaks
properly or append the .py extension, etc. I've Googled for this and
so far
it seems it doesn't exist. Anyone know?
 
R

Ryan Ginstrom

On Behalf Of Larry Bates
Since most of us keep Idle or some other Python IDE open
nearly 100% of the time we just copy from webpage, paste into
new Python document, and run in the IDE.
While you could clearly write a plug-in for FF to achieve
this, IMHO I doubt many people would actually use it.

Not that I'm going to implement it, but it would be really neat to tie
something together with codepad[1]

[1] http://codepad.org/
(With the site owner's permission, of course!)

Regards,
Ryan Ginstrom
 
P

Paddy

I encounter a fair number of small Python scripts online, and usually
try them out by copying them to the clipboard, pasting into Notepad,
saving them, and either running them directly or opening them in
IDLE.

And so I was wondering if anyone knew of an extension/add-on/script
for Firefox which would allow a way to do something like this:

user highlights Python code on a webpage
right clicks
selects a menu item, "Save as Python code"
FF pops up a filename dialog or popup for filename
(and, though I don't know if this is possible, runs Python code)

Not an important thing by any means, but it would be a nice
convenience.
I know there are similar add-ons in FF for grabbing highlighted text
and
saving, but they are not good, as they don't seem to preserve line
breaks
properly or append the .py extension, etc. I've Googled for this and
so far
it seems it doesn't exist. Anyone know?

Take a look at the crunchy project: http://crunchy.sourceforge.net/

- Paddy.
 
K

Kam-Hung Soh

I encounter a fair number of small Python scripts online, and usually
try them out by copying them to the clipboard, pasting into Notepad,
saving them, and either running them directly or opening them in
IDLE.

And so I was wondering if anyone knew of an extension/add-on/script
for Firefox which would allow a way to do something like this:

user highlights Python code on a webpage
right clicks
selects a menu item, "Save as Python code"
FF pops up a filename dialog or popup for filename
(and, though I don't know if this is possible, runs Python code)

Not an important thing by any means, but it would be a nice
convenience.
I know there are similar add-ons in FF for grabbing highlighted text
and
saving, but they are not good, as they don't seem to preserve line
breaks
properly or append the .py extension, etc. I've Googled for this and
so far
it seems it doesn't exist. Anyone know?

Not a Firefox add-on, but I found GnuWin32's "getclip" and "putclip" tools
useful. If you are familiar with shell tools, you can use "sed" to remove
leading indentation marks such as "> " before you paste sample code into
your IDE:

getclip | sed "s/> //" | putclip

See http://kamhungsoh.com/blog/2008/05/more-uses-of-getclip-putclip.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top