Ask Hackaday: How Do You Python?

Python is the Arduino of software projects. It has a critical mass of libraries for anything from facial recognition and neural networks to robotics and remote sensing. And just like Arduino, I have yet to find the killer IDE for Python. Perhaps I just haven’t tried the right one yet, but it could be that I’m just doing Python wrong.

For Years I’ve Been IDLE

IDLE with interactive shell that has highlighting and code completion

I’m a Linux-only type of a guy so using IDLE for Python is a natural fit. It’s in the repositories for super quick and easy install and there’s basically zero configuration to be done. Generally speaking my preferred development environment is text editor and command line compiler. IDLE is just one step above that. You get a separate window for the shell and each Python file you’re working on. Have IDLE run your code and it saves the file, then launches it in the shell window.

For me, there are two important features of IDLE’s shell. The first is that it keeps an interactive session open after you run your Python code. This means that any globals that your script uses are still available, and that you can experiment with your code by calling functions (and classes, etc) in real time. The second desirable feature is that while using this interactive shell, IDLE supports code completion and docstring support (it gives you hints for what parameters a function accepts/requires).

But simplicity has a tough time scaling. I’m working on larger and larger projects spread over many files and the individual nature of IDLE editor windows and lack of robust navigation has me looking to move forward.

The Contenders

I’ve tried perhaps a half-dozen different Python IDEs now, spending the most time on two of them: Geany and Atom. Both are easy to install on Linux and provide the more advanced features I want for larger projects: better navigation, cross-file code completion (and warnings), variable type and scope indication.

The look of Geany brings to mind an “IDE 1.0” layout style and theme. It’s the familiar three-pane layout that places symbols to the left, code to the right, and status along the bottom. When you run your program it launches in an interactive terminal, which I like, but you lose all IDE features at this point, which I despise. There is no code completion, and no syntax highlighting.

I have been using Atom much more than Geany and have grown to like it enough to stick with it for now. I’d call Atom the “IDE 2.0” layout. It launches with a dark theme and everything is a tab.

Atom has symbol view that isn’t shown all the time. CTRL-R brings it up and it uses a search style but you can also scroll through all symbols

Atom depends heavily on packages (plugins that anyone may write). The package management is good, and the packages I’ve tried have been superb. I’m using autocomplete-python and tabs-to-spaces, but again I come up short when it comes to running Python files. I’ve tried platformio-ide-terminal, script, and runner plugins.  The first brings up a terminal as a bottom pane but doesn’t automatically run the file in that terminal. Script also uses a bottom pane but I can’t get it to run interactively. I’m currently using runner which has an okay display but is not interactive. I’ve resorted to using a “fake” python file in my projects as a workaround for commands and tests I would normally run in the interactive shell.

Tell Us How You Python

It’s entirely possible I’ve just been using Python wrong all these years and that tinkering with your code in an interactive shell is a poor choose of development processes.

What do you prefer for your Python development? Does an interactive shell matter to you? Did you start with IDLE and move to a more mature IDE. Which IDE did you end up with and what kind of compromises did you make during that change. Let us know in the comments below.

Car Idle Alarm Helps You Stop Wasting Gas While Tweeting

[TVMiller] has a bone to pick with you if you let your car idle while you chat or text on your phone. He doesn’t like it, and he wants to break you of this wasteful habit – thus the idle-deterrence system he built that he seems to want on every car dashboard.

In the video below, the target of his efforts is clear – those who start the car then spend time updating Twitter or Instagram. His alarm is just an Arduino Nano that starts a timer when the car is started. Color-coded LEDs mark the time, and when the light goes red, an annoying beep starts to remind you to get on with the business of driving. The device also includes an accelerometer that resets the timer when the vehicle is in motion; the two-minute timeout should keep even the longest stop light from triggering the alarm.

[TVMiller] plans an amped-up version of the device built around an MKR1000 that will dump idle to moving ratios and other stats to the cloud. That’s a little too Big Brother for our tastes, but we can see his point about how wasteful just a few minutes of idling can be when spread over a huge population of vehicles. This hack might make a nice personal reminder to correct wasteful behavior. It could even be rolled into something that reads the acceleration and throttle position directly from the OBD port, like this Internet of Cars hack we featured a while back.

Continue reading “Car Idle Alarm Helps You Stop Wasting Gas While Tweeting”

Cheap Multimeter Gauges Embedded Idle Time

How often is your microcontroller actually doing something? You can find out by measuring idle time, but how exactly do you do this? [Jack Ganssle] shows that simple embedded applications can toggle a pin when idle, which can then be measured. More complex applications like those using a Real Time Operation System can do the same by making use of the idle hook. But what can you do to make this toggling pin feedback actually mean something?

His solution is to repurpose an analog multimeter. The meter is interface with the toggle pin and a trimpot calibrates the needle. This way the needle jumps when the processor is busy and returns to zero when idle. What a great tip for getting a little more feedback about what’s going on inside of that black plastic IC package. It’s not surprising to find such a clever hack from one of the Hackaday Prize judges.

While you’re in the analog multimeter aisle you might want to pick up a couple of extras for more alternate data displays.

Continue reading “Cheap Multimeter Gauges Embedded Idle Time”

Take the python challenge


It’s hard to believe that we haven’t covered this one before. If you enjoyed out Barcode challenges from last week, perhaps now is the time for you to take the Python Challenge. We made it through the first 18 levels about a year back but with a total of 33 levels we’re not even close to being finished.

This is an excellent opportunity to learn Python if you’ve never tried it, or test your skills if you’ve already got them. We’d suggest using IDLE which is available as part of the Python language download. Because Python is an interpreted language, IDLE allows you to try out each line of the code you are writing and add it to your program as you get different sections working.

The levels start out fairly easy and require some sniffing around, such as looking at the source code, and dissecting images with Python’s various libraries. As you pass each level, you will be granted access to the Python Challenge forums in order to see how others solved the level. By solving each level and then seeing what different solutions entail you grow your knowledge of the language and reinforce your understanding of how to use it.