Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

VideoBeagle

macrumors 6502a
Original poster
Aug 17, 2010
822
18
App Q&A testing by request.
I've seen there is a way to use Applescript Editor as a python IDE.

Anyone know how this is done?

(see attached pic).

It's from a Coursera Python class I'm taking..just screen shots to show you installed the program (intro course). Peer grading...it's anonymous, so I can't ask the person who's screen it is how she did it (well, in a shot of her terminal, she left her whole name, so I could likely find her, but I'd like to avoid being too stalkery if i can :).
 

Attachments

  • access.png
    access.png
    366.6 KB · Views: 790

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
Your screenshot just shows a regular AppleScript - print is a valid command, although in this case it will throw an error when run because the string is not a valid file path. I haven't seen any plugins, so as far as I know, the AppleScript Editor will only run AppleScripts.

You can use other text editors such as TextWrangler to manage projects and run Python scripts directly from the editor (or from the Terminal) using your installed version.
 

VideoBeagle

macrumors 6502a
Original poster
Aug 17, 2010
822
18
App Q&A testing by request.
Your screenshot just shows a regular AppleScript - print is a valid command, although in this case it will throw an error when run because the string is not a valid file path. I haven't seen any plugins, so as far as I know, the AppleScript Editor will only run AppleScripts.
...

Hmm..You know...I tested it on my Script Editor, got the expected errors, and thought to myself "Well it must be working as she doesn't have the errors, and that's a long way to go to not install TextWrangler (which is the recommended editor for the class)." I didn't notice she hadn't actually hit run in the screen shot.

Yeah, my google searching came out zilch. I use TextWrangler already for the little python stuff I know, but I've always liked AppleScript's color coding and layout, and if there was away to get it to work with Python, that'd be great. Guess not :/
 

chown33

Moderator
Staff member
Aug 9, 2009
10,753
8,443
A sea of green
If AppleScript Editor were really interpreting Python, then the little popup menu that shows "AppleScript" next to "<No selected element>" wouldn't be showing "AppleScript". It'd be showing some other language, like, well, "Python".

Theoretically, there can be dialects or languages other than plain ordinary AppleScript. I think these are called something like "OSA Language components". For example, googling osa language finds this:
http://en.wikipedia.org/wiki/JavaScript_OSA
which is basically JavaScript with some OSA inter-process stuff.

It's not a standalone OSA language component (I think), but I think those are possible (or were at some point in time). I don't recall any names, since alternate OSA languages tend to be niche products. Nor do I recall if another component is needed in order for AppleScript Editor to use the alternate OSA language.

See here for some details:
https://developer.apple.com/library...ipt/conceptual/applescriptx/concepts/osa.html
 

hhas

macrumors regular
Oct 15, 2007
126
0
Theoretically, there can be dialects or languages other than plain ordinary AppleScript. I think these are called something like "OSA Language components". For example, googling osa language finds this:
http://en.wikipedia.org/wiki/JavaScript_OSA
which is basically JavaScript with some OSA inter-process stuff.

OSA is a plugin mechanism for scripting language interpreters. In theory, an OSA-aware application can load and run scripts written in any scripting language, as long as an interpreter for that language has been packaged as a C-based Component Manager component. CM was basically the classic Mac equivalent to Windows' COM, commonly used for Quicktime codecs plugins and other dynamically loaded code bundles, though it's pretty much been superseded by NSBundles and ObjC classes.

In practice, however, AppleScript is the only OSA language that has ever been good enough for production use. The only third-party OSA language components were either really, really limited in capability, or didn't work quite right (e.g. Mark Aldritt's JavaScriptOSA or my own PyOSA, both of which are long-dead). Plus the Carbon Component Manager API was deprecated in 10.8, so any third-party OSA components are dead in the water nowadays anyway. (Apple have added a new 'JavaScript for Automation' OSA component in 10.10, but it's full of crippled features and application incompatibilities, so while it might do for light use with some apps I would not touch it for serious production work either.)


Getting back to Python editors... As others have noted, the OP's screenshot is basically fake: you can write Python code in any text editor (even Script Editor), but you won't get syntax highlighting or be able to run it unless you use an editor that has those features built in. Even if you did have a working Python OSA component, SE's a miserably poor tool. Personally, I use TextWrangler - it's basic but free (I recommend customizing the preferences to bind the Run menu item to Cmd-R). There's plenty other options if that's not to your taste - the Python wiki includes a list of editors which may be a useful starting point.
 

afro-ninja

macrumors member
Jan 27, 2013
44
4
YEah...I got snookered.

(Anyone know a more..color coding set syntaxing type editor for Python, other than IDLE or TextWrangler.)

I use Eclipse with the add-on PyDev. It's a bit of hassle to set up (you must manually install Java JDK 7 first, and install the right Eclipse from the different options otherwise it won't work...), but it's exactly what you're looking for. Color coding, runs within the editor etc :)
 

mw360

macrumors 68020
Aug 15, 2010
2,032
2,395
I use Komodo Edit. It's free. No tricky set-up. Python just works (for me anyway). Syntax colouring and checking, loads of other handy stuff. Press cmd-R to run your script inside the editor.
 

Freez

macrumors newbie
Feb 9, 2011
15
0
BBEdit

I use BBEdit. It seems to work well with python. BBEdit has saved me countless hours with regex in the find/replace. Also, it can select text in a document by the column.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,753
8,443
A sea of green
I use BBEdit. ... Also, it can select text in a document by the column.

Even TextEdit can do rectangular selection. Simply hold down the OPTION key, then click and drag. The selection will expand/contract as a rectangular area, rather than by whole lines.

If you also hold down the CMD key, you can then select discontiguous rectangular areas.
 

VideoBeagle

macrumors 6502a
Original poster
Aug 17, 2010
822
18
App Q&A testing by request.
Even TextEdit can do rectangular selection. Simply hold down the OPTION key, then click and drag. The selection will expand/contract as a rectangular area, rather than by whole lines.

If you also hold down the CMD key, you can then select discontiguous rectangular areas.

Woah..something new learned!

Thanks for all the editor recomendations!
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,564
6,062
I use Eclipse with the add-on PyDev. It's a bit of hassle to set up (you must manually install Java JDK 7 first, and install the right Eclipse from the different options otherwise it won't work...), but it's exactly what you're looking for. Color coding, runs within the editor etc :)

No. Eclipse is a bloated piece of garbage. It doesn't handle Java (the language it was made for) well and it handles everything else worse.

I find that just going with a text editor that can offer autocompletion and text highlighting (like sublime) + a console is best for most Python projects. If you need to do stuff like remote debugging (IE, if you're using Django) you may want to use a good IDE, such as PyCharm.

Never settle for the crap that is Eclipse.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.