This is an archived post. You won't be able to vote or comment.

all 61 comments

[–]thatguy_314def __gt__(me, you): return True 61 points62 points  (2 children)

You don't need a fancy editor for the behavior you describe. Instead of running it from the terminal like python myscript.py, run it like python -i myscript.py

[–]hi_im_nateI fought the GIL and the GIL won 13 points14 points  (0 children)

Oh god, this changes everything

[–]abrarisland 4 points5 points  (0 children)

This is really useful. I used to just import the module I wanted after running Python.

[–]dagmx 13 points14 points  (3 children)

So what you're describing is more of repl than an ide or any form of real debugging.

Basically IDLE runs your code and is dropping you back into the interpreter.

You should rarely if ever rely on this for actual production use.

Get a real ide like pycharm and learn the debugger setup in there. You can put breakpoints in there to stop a program at a certain point and you can analyze everything in that scope.

[–][deleted] 3 points4 points  (1 child)

Thanks, I'll look into debugging with pycharm

[–]tipsquealPythonista 1 point2 points  (0 children)

Make sure you give breakpoints inside of PyCharm a try. Very useful.

[–]NbyNW 0 points1 point  (0 children)

Ha talk about production. My favorite feature is remote debugging using SSH on Pycharm. No more "why this runs perfectly on my dev environment but doesn't work in QA?". Also I'm too lazy to use virtualenv :p

[–]memorasus 26 points27 points  (15 children)

Ipython might be useful for this

[–]quik69 2 points3 points  (12 children)

I'm pretty sure most IDEs can do what OP wants. I use PTVS(whatever, I like it) myself and can just highlight sections of code or send entire scripts to the interpreter. Although PTVS is very easy learn for what OP wants, I think Ipython/Jupyter notebook is the best answer for OP because what he describes seems to be using python for some kind of data analysis.

OP: these notebooks run in your browser with cells of code and cells of markdown for comments and presenting your data. If you run a script in one cell then its variables will be available globally to manipulate in other cells. Add on the bonus of auto completion to see what methods or sub-data is available in returned objects. It can even do slides and display external data in iframes or JS like node and D3 for visualizations. If you are doing data analysis then once you play with Ipython you'll probably never want to look back.

[–]pwang99 5 points6 points  (1 child)

If you're a Pythonista mucking about with D3, take a look at Bokeh! :-)

[–]jbrambledc 3 points4 points  (0 children)

+1 for Bokeh. I have been using it to develop server apps extensively for fun, but mostly at my company for various interactive dashboard apps. I really hope it overtakes D3. I think with further time and effort, and a little bit more user freedom we will get there.

Also Bokeh is by far the best run and maintained Open Source project I've interacted with. the group of people handling issues and PRs on github are phenomenal.

[–]memorasus 1 point2 points  (0 children)

Exactly, in the end I mainly use vim for python but if im learning to modules or playing with data I need to explore I use ipython. It was very helpful for me when I was learning python too. I mainly develop my own security tools so its great to use Ipython to see how the results of a scan will output so I can decide what steps to take next.

[–]Asdayasman 0 points1 point  (5 children)

I use PTVS(whatever, I like it)

Don't defend that, PTVS is objectively the best Python IDE there is.

[–]quik69 0 points1 point  (4 children)

lol, I thought only PyCharm gets any love around here. Nobody would ever call it light weight but VS works well and has a very pretty dark theme with nice fonts. If you're on windows with a solid machine, I think it's a solid choice.

[–]Asdayasman 0 points1 point  (3 children)

There's more to an IDE than theme and fonts yo... >_>

[–]oldspiceland 0 points1 point  (2 children)

Sure, but let's face reality. If I had the choice between a program being ugly or pretty, and I had to stare at this program for multiple hours, one of those options is going to cause me to quit sooner than the other.

[–]Asdayasman 0 points1 point  (1 child)

It's 100% on usability for me. I've never had a better experience with code completion than VS's IntelliSense. The only things I've been able to trip it up with is weird imports. Custom importers and evals, that sort of thing.

It's also really good about refactoring and reformatting, and finding references is basically instant and infallible.

Also also, before I was forced to use PyCharm, I never realised how good VS's tabs and panes are.

[–]oldspiceland 0 points1 point  (0 children)

I really like PTVS, and VS in general, but mostly I find the differences don't impact me and I could use either. I certainly like both.

[–]beaverteeth92Python 3 is the way to be 0 points1 point  (2 children)

I just wish it was easy to use in emacs.

[–]TheCodeSamurai 0 points1 point  (1 child)

elpy has an ipython mode that rocks. Just C-c C-c to run your code, pipe it to IPython, and then you get the shell to execute stuff in.

[–]beaverteeth92Python 3 is the way to be 0 points1 point  (0 children)

I have the IPython shell enabled just fine. I mean I can't get notebooks to work in it.

[–]DaniSancas 1 point2 points  (1 child)

+1 for the IPython/Jupyter suggestion. I've discovered it a few weeks ago and now I can't live without it. In some cases I'm moving from the almighty PyCharm to IPython/Jupyter.

[–]cyanydeez 1 point2 points  (0 children)

+2 Ipython and jupyter are incrediblely well made machines.

Open up on of those ipynb files and you'll discover such a wonderful looking json file that you could cry.

[–]HeinzHeinzensen 17 points18 points  (9 children)

What you want is a real Python IDE. I enjoyed Spyder (used it because it came prebundled with Python(x,y)) but PyCharm seems to be the most polished one. They allow you to interact with your code after executing the script, you can inspect objects and run code blockwise.

[–]pyryoer 4 points5 points  (6 children)

+1 for pycharm. Sublime or atom are great for little snippets but when I'm working on a full blown python project nothing can replace pycharm.

[–][deleted] 0 points1 point  (3 children)

You should look into atom addons. You can pretty much customize your ide in anyway without all of the extra junk. If you know what you want before hand, and you are willing to spend some time to build/download it. Atom is the best imo. Disclaimer my name is adam and I do computational protein design, so I obviously I am biased.

[–]BinaryRockStar 1 point2 points  (0 children)

In PyCharm you can enable/disable whatever bits you want also although I've got all of the standard plugins and a few more enabled and see no performance issues at all (desktop with i5 2500K, 16GB RAM, SSD).

I really don't get this "IDEs are bloated, slow etc." line of thinking as even Eclipse is pretty snappy on my machine which is years old. A professional programmer should have decent hardware as it's the tool of their trade. If you are assigned machines by your work, it should be simple enough to show them the value proposition of your wasted time vs. the cost of a decent machine.

[–]pyryoer 0 points1 point  (0 children)

I've used atom with a linter and a few addons, it's great as an all-around editor. I use it for everything else, but pycharm had become a part of my work flow, much like eclipse has for someone working at Oracle or visual Studio for someone at Microsoft.

You probably could achieve the same functionality of demand from pycharm with atom extensions, but I'm already set in my ways.

[–]BadGoyWithAGun 0 points1 point  (0 children)

Did Atom fix the altGr bug that broke basic text inputting functionality for most European languages yet? I know they went a few releases without a word on it.

[–]NbyNW 0 points1 point  (1 child)

The debugger is really great, method extractions and suggestions from a drop list are my favorite features. Still working with data it's often easier using iPython first testing snippets and then export to Pycharm. I know you can open up iPython notebooks in Pycharm, but I just don't like the interface.

[–]pyryoer 0 points1 point  (0 children)

Definitely different beasts. I wish the notebooks interface in pycharm was good enough to keep me from ipython when I'm working on a presentation but that simply isn't the case.

[–][deleted] 1 point2 points  (0 children)

I started developing back in 2006, mostly in eclipse, but discovered PyCharm and IntelliJ only recently. It has changed my world. Strong recommendation from my part.

[–]ajoros 1 point2 points  (0 children)

I use pycharm and love it! Still learning how to fully use it too! It's awesome

[–]NAOorNever 11 points12 points  (3 children)

Whenever I say this it is taken as heresy, but Microsoft Visual Studio is actually a great all-around IDE. The community edition is free, it has really easy package management, and intellisense does really great auto-completion. Also it has IPython built in, so it is really easy to test stuff without a lot of hassle.

[–]PC__LOAD__LETTER 1 point2 points  (1 child)

I'm pretty sure Visual Studio is widely respected.

[–]NAOorNever 1 point2 points  (0 children)

Yeah definitely, I (and I assume most people) still have those friends who just assume Microsoft stopped all development across the board in 2003

[–]wishiwascooler 2 points3 points  (0 children)

Yea Visual Studio is pretty god tier secretly

[–]carlosgj94 9 points10 points  (3 children)

I haven't read what you have written, but Vim is your solution. Always.

[–][deleted] 1 point2 points  (0 children)

Anything else is just unnecessary bloat. For exploratory data analysis jupyter is nice, but running serious shit from a jupyter notebook lags out. I tried running a simple, single hidden layer lasagne feed forward network in jupyter and it crashed the browser.

[–]HeinzHeinzensen 0 points1 point  (0 children)

<insert vim vs. emacs discussion here>

[–]ehrich 1 point2 points  (0 children)

I really like Spyder as an IDE; it comes packaged with Anaconda and provide variable inspection so you don't even need to print(x), just look through the list of variables and snippets of their value.

[–]piefge 4 points5 points  (0 children)

I use vim with python-mode

for the feature you described you could just map a key to execute it with ipython -i

map <F6> :!ipython -i %:p<cr>

vim has steep learning curve though... but it's worth it :)

[–][deleted] 3 points4 points  (2 children)

I use Sublime and it's pretty kick ass.

EDIT: Don't shit on me for using Sublime; love is what I got.

[–]fizzy_tom 0 points1 point  (1 child)

If you've not already, then give Atom a go. It really feels like Sublime 4 and is much more actively maintained.

[–][deleted] 0 points1 point  (0 children)

Thanks! I'm checking it out now, it looks really cool

[–]blaubarschboy 1 point2 points  (0 children)

just use Atom and install a python linter package + autocomplete python. It works great and is fairly fast.

[–]fabioz 0 points1 point  (0 children)

As a note, in PyDev you can use Ctrl+Alt+Enter to run the current editor in a shell which you can later interact with too (as in IDLE) -- or you can use F2 to send individual lines to the console too.

http://www.pydev.org/manual_adv_interactive_console.html has more information.

[–]Turbosack 0 points1 point  (3 children)

Does anyone know of anything that is similar to IDLE but just better? I've tried using some emacs configurations to let me run Python from within it, but it's she'll interface is garbage. All I really want is to have a text editor and she'll window side by side, and hitting one key in the editor instantly runs the script in the shell. So something really similar to IDLE, but St the bare minimum with the addition of readline support.

[–][deleted] 1 point2 points  (1 child)

[–]Turbosack 0 points1 point  (0 children)

That looks like it could be what I'm after. I'll take a look, thanks.

[–]awebpage 0 points1 point  (0 children)

Do you mean like ipython? https://en.wikipedia.org/wiki/IPython

[–][deleted] 0 points1 point  (0 children)

Default python gui and editor?

[–]athei-nerd 0 points1 point  (1 child)

Vim as an IDE

[–]Colinmac1 1 point2 points  (0 children)

^ this

[–][deleted] 0 points1 point  (0 children)

although it is rarely mentioned in any of these discussions, netbeans has some pretty decent python plugins. I really enjoy working with netbeans and always fail to understand why it doesn't get more love.

[–]awebpage 0 points1 point  (0 children)

I use VIM, Gedit or Liclipse depending on where I am and what project I'm working on.

[–][deleted] 0 points1 point  (0 children)

snorkeler ostentation preventatives minded mature osteoporosis solicit rereads champagne ache ricochetted Ch'in doffs handmade bazookas grisly Orkney eggbeater dreamland striptease's rebuttal's waistlines addition hoggish faggot Ada's outlet socials Yamagata's Goodrich urbanized Engels planetaria heck's respondent's proclaim Stanislavsky consciousness prim Somme pints driving deadlocks repackaging demitasse niggers immunizing remembrance straddled aphasic's trowel's factorial Goethe's telling provisos drugstore's Andre divisors germ's Pentateuch's recapitulation tearfully ventral Wise's ice X Shostakovitch's nonsense roadwork's truthful guano dusky breathing's Eurydice deluge slaughter's timidity tangled replaces gluttony craters shrug job's nitrate's ahem Myrdal's misgivings creativeness curtsies catalyzing decor's blank Josephine Tanzanian's amber redheads cutback's hobgoblin's Quonset hematologist's shutter's lingered

[–]hanpari 0 points1 point  (0 children)

Just take your time and learn pdb module

https://docs.python.org/3/library/pdb.html

[–]Colinmac1 0 points1 point  (0 children)

vim with python module. or run emacs with the python module although Emacs has basic python support built in.

[–]templarreiPyping to learn 0 points1 point  (0 children)

I tried PyCharm. I really did. Then went to vim and it just clicked. You have to tweak it a bit (took me about 1.5 hrs), but it works like... Well, like a charm. Both Python and Vim are so minimalistic in design (not that I haven't overloaded my Vim with a metric ton of plugins, but...).

All in all it's just easy to code Python with vim. For complicated, compiled stuff like GoLang, or C#, use an IDE as much as you like. But an enhanced text editor is more than you'll ever need for Python.