Editor for Python on Mac

Posted on
Fri Feb 12, 2016 7:29 pm
canalrun offline
Posts: 80
Joined: Jan 17, 2016

Editor for Python on Mac

Hello,
Which editor do people use to create Python files on the Mac?

As I understand it, a Python file is just a text file with a .py extension.

I'm PC guy, software engineer for 30 years.

On the Mac, I am using TextEdit. By default this does RTF files, but searching the Internet I found a way to make it do text files.

Then simple scripts, such as myVar = "true", caused illegal syntax errors.

After quite a bit of messing around, I found "smart quotes" was turned on so the quotes were not really quotes as Python expected them.

I figured out how to get rid of these smart quotes and turn them off by default. After that, everything worked great.

I'll be honest, I think Apple is garbage. :x

Is TextEdit the best choice for creating Python files? Is there something better? (Simple and free?)

Barry.

Posted on
Fri Feb 12, 2016 8:46 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Editor for Python on Mac

No, don't use TextEdit. Best FREE programming editor is TextWrangler. http://www.barebones.com/products/textw ... nload.html

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Feb 12, 2016 9:01 pm
RogueProeliator offline
User avatar
Posts: 2501
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Editor for Python on Mac

I'm PC guy, software engineer for 30 years.

The new Visual Studio (Visual Studio Code) might give you a good option; being from Microsoft it isn't maybe as "Mac-like" as some. Python support is basic right now, but the feature to support it more robustly has enough votes to have it being reviewed for inclusion. It is free as well.

Adam

Posted on
Fri Feb 12, 2016 9:11 pm
DaveL17 offline
User avatar
Posts: 6744
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Editor for Python on Mac

+1 for TextWrangler (it's my main editor.) I've also been given advice to try PyCharm, but haven't pulled the trigger on that.

Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Feb 12, 2016 9:28 pm
Herbo offline
User avatar
Posts: 10
Joined: Jan 02, 2007
Location: Annapolis, MD

Re: Editor for Python on Mac

Try CodeRunner. Works great. https://coderunnerapp.com


Sent from my iPad using Tapatalk

Posted on
Fri Feb 12, 2016 10:15 pm
canalrun offline
Posts: 80
Joined: Jan 17, 2016

Re: Editor for Python on Mac

Thanks for all the suggestions.

I downloaded and installed TextWrangler.

I think that will work very well for what I need to do.

Barry.
Last edited by canalrun on Fri Feb 12, 2016 10:16 pm, edited 1 time in total.

Posted on
Fri Feb 12, 2016 10:15 pm
Bollar offline
Posts: 528
Joined: Aug 11, 2013

Re: Editor for Python on Mac

I use Sublime Text.
http://www.sublimetext.com

Insteon / Z-Wave / Bryant Evolution Connex /Tesla / Roomba / Elk M1 / SiteSage / Enphase Enlighten / NOAA Alerts

Posted on
Fri Feb 12, 2016 11:09 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Editor for Python on Mac

I used Xcode for 2 years, but had to switch to text wrangler. Xcode does not work well with headless setup (pure mac setup using screen sharing :( ). Xcode looses the mouse after 5 minutes.
After switching and going through the growing pain. I am actually happy with text wrangler. Miss some nice features of Xcode though especially the find function has some nice options

I guess they all work, just a matter of getting used to it.


Other major question you should settle if you want to use tab or expanded tabs (replace tab with 4 spaces)

Initially I had tab but switched to expand tabs to 4 spaces as I was using some external code. Most it is written with 4 spaces. When you copy and paste and you are using the different conventions the whole thing gets really screwy. To make sure you do the right thing set edit/edit options/ show invisibles and show spaces to ON, at least until you are sure about that setting.


Karl

Posted on
Sat Feb 13, 2016 4:07 pm
andarv offline
Posts: 126
Joined: Jun 28, 2015
Location: Stockholm, Sweden

Re: Editor for Python on Mac

I tried PyCharm. I guess it has some really nice features. But whenever I wrote something in the program and copy /pasted it to Indigo the code never worked.
And it warns a lot that my code sucks..
I can't say that I looked into all the settings so you can probably sort out the issues I had.
I'm really inexperienced in coding so I switched back to notepad. Maybe should try text wrangler?

Posted on
Sat Feb 13, 2016 4:16 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Editor for Python on Mac

andarv wrote:
Maybe should try text wrangler?


Definitely. It's way better than most alternatives.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Apr 07, 2016 1:44 pm
hishamk offline
Posts: 14
Joined: Aug 15, 2015

Re: Editor for Python on Mac

Sublime is good, but if you're working with substantial projects, I'd definitely recommend Pycharm.


Sent from my iPhone using Tapatalk

Posted on
Thu Apr 07, 2016 3:14 pm
gazally offline
Posts: 27
Joined: Jan 18, 2016
Location: Bigfoot country

Re: Editor for Python on Mac

canalrun wrote:
I'm PC guy, software engineer for 30 years.

If you've been in software for 30 years I bet you've heard of Emacs and either love it or hate it. Either way, it is included with OS X. I use a package called elpy that makes it into a Python IDE.

Posted on
Sun Sep 22, 2019 11:03 am
mgolden50 offline
User avatar
Posts: 247
Joined: Jan 29, 2007
Location: Chandler, AZ

Re: Editor for Python on Mac

I’m not sure if this is the right topic in which to post this but here goes.

A bit of background: I have no formal training in Computer Science. After the advent of the Altair 8080 personal computer in 1978, I taught my self assembly language coding. With that skill I developed realtime communication and process control systems that were deployed by all of the major TV networks and Baby Bells. I bought my first Mac in 1984 and never looked back. As the scale of my projects increased I was now hiring “real” engineers who were using C and C++ to implement my projects. I never felt compelled to learn the intricacies of object oriented coding they were using although I understood the principles.

But as a hobby I loved HA and automated two homes in the early 80’s (all pre Insteon Lutron and even X-10, etc.) using low voltage wiring runs to control and sense switches. With my series of evermore capable Macs I began using HyperCard and eventually SuperCard mixed with AppleScript. AppleScript ultimately became my preferred software tool for my hobby. In the early 2000’s, after dabbling with a number of less than adequate HA software tools, I discovered Indigo (Oh Joy!!) and was delighted at it's use of AppleScript to extend the capabilities of the excellent Indigo software. And, of course, the ever-growing base of amazing plugins created by Indigo's band of loyal users further enhanced the fun because they enabled controlling the ever-growing base of consumer HA products (all of them but especially Alexa).

Coding Indigo action scripts with AppleScript was simple because of two things: 1) the excellent examples provided by Matt and Jay in their tutorials which I could cut, paste, and modify and, 2) the ability to cut, paste, and modify the seemingly unlimited AppleScript code snippets found on the Internet to accomplish more difficult and/or complex functions including command line shell scripts.

But then…
Application not running errors
Apple deprecates AppleScript
Indigo deprecates AppleScript and sings the praises of Python.
My worst fear… At 78 I now needed to master a new programing language… I may not have the time!

So I’ve begun. I can now successfully replace most lines of AppleScript with lines of Python.

But I’m still missing the complete development environment that AppleScript provided, namely the ability to write and run scripts in the Script Editor app with full control of Indigo. After trying a number of Python editors and not finding a run command available. I finally read DaveL17's and Jay’s comments about BBeditor. It has every thing I think I need tor testing Python code snippets except when I use “import indigo” it doesn’t work to connect me to the Indigo functions.

I have entered into the terminal: echo "alias indigohost='/Library/Application\ Support/Perceptive\ Automation/Indigo\ 5/IndigoPluginHost.app/Contents/MacOS/IndigoPluginHost'" >> ~/.bashrc
And then into a new terminal window: indigohost -i
I don’t see the expected: “Connected to Indigo Server” result.

What am I doing wrong? Cook book instructions for doing this would be great!

Sorry for the rambling,

But, many thanks to Matt and Jay as well as to plugin authors: FlyingDiver, Autolog, Perry the Cynic, Glenn’s Plugins, Nathan Sheldon, Mike Poulson, Travis, Howartp:

Posted on
Sun Sep 22, 2019 11:30 am
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Editor for Python on Mac

Indigo has the scripting shell built in (under the Plugins menu), which is good enough for testing small snippets of code.

For slightly larger code samples, I usually just create an action group with a scripting action and put the code there. No IDE per se, but good enough for testing some things.

For plugins, you can run them in a debugger. If you want a full IDE in the debugger, you can use PyCharm. Do a search on these forums for it. I don't know if you can use it for scripts.

Personally, I use BBEdit with lots of debug logging statements 95% of the time. I learned to code before IDEs and just never got the hang of most of them. I do use Xcode when I have to.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Sep 22, 2019 1:29 pm
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Editor for Python on Mac

We know that transitioning from AppleScript comes with challenges, particularly for those that aren't from software development background. To that end, I'm working on a new wiki article that may be of some help. I'm not done yet, and if anyone has any thoughts on other things to add (like debugging) feel free to let me know.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Who is online

Users browsing this forum: No registered users and 2 guests