I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool.
However, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language.
How important is an IDE to normal Python development?
Are there good IDEs available for the language?
If you do use an IDE for Python, how do you use it effectively?
IDEs arent very useful in Python; powerful editors such as Emacs and Vim seem very popular among Python programmers.
This may confuse e.g. Java programmers, because in Java each file generally requires boilerplate code, such as a package statement, getters and setters.
Python is much more lightweight in comparison.
If you're looking for an equivalent to Visual Studio or Eclipse, there is... Eclipse, with Pydev.
Emacs and Vim are very powerful and general, but have a steep learning curve.
If you want to use Emacs, I highly recommend python mode; it's much better than the default Python mode.
A matter of habit and personal preferences. Me, I use vim (I have to admit emacs is at least as powerful, but my fingers are deeply trained by over 30 years of vi, and any other editor gives me the jitters, especially when it tries to imitate vi and never really manages to get it 100% right;-), occasionally an interactive environment (python itself, sometimes ipython), and on even rarer occasions a debugger (pdb). A good editor gives me all I need in term of word completion, lookup, &c.
I've tried Eclipse, its plugins, eric, and Kommodo, but I just don't like them -- Wing, I think I could get used to, and I have to admit its debugger is absolutely out of this world... but, I very rarely use (or need!) advanced debugging functionality, so after every rare occasion I'd forget, and have to learn it all over again a few months later when the need arose again... nah!-)
How important is an IDE to normal Python development?
Not very, IMHO. It's a lightweight language with much less boilerplate and simpler idioms than in some other languages, so there's less need for an IDE for that part.
The standard interactive interpreter provides help and introspection functionality and a reasonable debugger (pdb). When I want a graphical look at my class hierarchies, I use epydoc to generate it.
The only IDE-like functionality I sometimes wish I had is something that would help automate refactoring.
Are there good IDEs available for the language?
So I hear. Some of my coworkers use Wing.
If you do use an IDE for Python, how do you use it effectively?
N/A. I tried using Wing a few times but found that it interfered with my normal development process rather than supporting it.
The IDE you use is a personal and subjective thing, but it definitely matters. Personally, for writing short scripts or working with python interactively, I use PyDee available at http://pydee.googlecode.com/ . It is well done, fairly lightweight, but with good introspection capabilities.
For larger projects involving multiple components, I prefer Eclipse with appropriate plugins. It has very sophisticated management and introspection capabilities. You can download it separately or get it as part of Python (X,Y) at http://www.pythonxy.com/ .
In contrast to the other answers i think that IDE's are very important especially for script languages. Almost all code is bad documentated and an IDE with a good debugger gives you much insides about what is really going on what datatypes are assigned to this values. Is this a hash of lists of hashes or a list of hashs of hashs.
And the easy documentation lookup will save you time.
But this is only important for people who need to count there time, this normally excludes beginners or hobbyists.
(1) IDEs are less important than for other languages, but if you find one that is useful, it still makes things easier. Without IDEs -- what are doing? Always running Python from command line?
(2-3) On my Mac there's included IDLE which I keep always open for its Python shell (it's colored unlike the one in Terminal) and I use free Komodo Edit which I consider to be well-suited for Python as it doesn't go into the language deeply but rather focuses on coloring, tab management, parsing Python output, running frequent commands etc.
Related
I really loved this feature when I used Eclipse for Java programming, but I can't find the same functionality for a Python editor. IDLE and Pyscripter are nice, but they don't help in this area.
Basically, I just want the option to collapse or otherwise hide functions that I don't feel like looking at for a while. Know of anything like this?
In addition to the aforementioned (great) editors, you might want to give PyDev a shot as well.
Geany can do this.
Notepad++ has this feature.
Komodo Edit IDE, for Windows, Mac and Linux, for Python, PHP, Ruby, JavaScript, Perl and Web Dev.
I've used Komodo Edit and Notepad++ in the past but my current preference is Sublime Text Edit 2.
Although not free (and actually quite expensive), it can be used in free mode with only an occasional reminder and no other restrictions.
It is actually written in Python so you get a Python console built in - you can also get other consoles such as JavaScript. It is VERY flexible & has some very good features. It is also has an excellent community with loads of very useful plugins.
It is much lighter on resource usage than Komodo, can use Textmate bundles directly (so gets loads of formatting options for different file types). It is cross-platform and doesn't even need installation on Windows.
Pycharm CE, from Jet Brains, indeed, wonderful. Functions and comments collapse is ready out of the box, as well as edit helpers. Project files and assets organization, integrated python console, powerful debugging tools,... Then, lots of plugins: git integration, tinycode view, extra languages' helpers and highlighters,.... anything you need when coding, but simple and easy to use. There's a Pro (paid) version for those who want even more.
https://www.jetbrains.com/pycharm/download
(This question is more than 10 years old. I got surprised, nobody answered about Pycharm before...)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
Basically, me and a friend of mine are just planning to work on a Python project which would have GUI interface, and enable file transfer over and remote file listing. We have most of the tools which we are going to use, Glade, Python etcetera.
I just want to know if I should use an IDE or not.
I've heard only good things about Anjuta, but not convinced of its Python support; care to comment?
And also is there any other good IDE I should check out?
Currently I am just planning on coding as usual in vim.
The ability to debug using an IDE makes your life so much easier.
Python is a particularly strange language in that having a full-fledged IDE doesn't really add much (and some would argue that an IDE tends to severely limit your thinking-flow in Python). I've been using regular Vim and Gedit to develop in Python and never really missed using IDE.
Text editors like Vim or Emacs itself can be configured quite flexibly to match an IDE power though, so it doesn't really matter which way you go.
There are numerous IDEs you can check out. Take a look at PyDev, PIDA, Komodo, Eric.
I personally don't think IDEs add that much to software development (on this scale and in this language). Python has fine external debugging tools and refactoring is not that hard with a program of this size.
Do you currently use or want to use any features you miss in your current editor? If so, pick another one, else, stick with what you like most.
As long as it has version control integration you should be fine.
Personally I do most my Python coding in Vim, but once in a while I feel like using a full-IDE and I use Eclipse with Pydev at those times.
It depends on your own preference, some people absolutely love Vim and won't use anything else. Others just can't work without an IDE.
Here's a list of:
Python IDEs: http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
Python editors: http://wiki.python.org/moin/PythonEditors
In terms of using an IDE or not, it doesn't matter. I prefer using an IDE since I like having the tools I need bundled up into one nice, neat little package that can handle all of my development. However, using a text editor is just as good, especially ones as powerful and extensible as vi(m) and (x)emacs. The real reasons for using an IDE, though, are code completion, management of indentation, code folding, refactoring support, and debugging.
If you want to check out other IDEs for Python development, I would suggest also looking at NetBeans and Eclipse with the appropriate plugins. I, personally, prefer NetBeans since I have a feeling that PyDev is going to be going downhill since Aptana bought them (previously, they ruined RadRails, which is the Eclipse plugin for Ruby on Rails development) and don't want to get comfortable with a tool that might not be useful long-term.
With Java, I'd say no IDE for beginners, because you have to understand CLASSPATH first.
With Python, I'd say PyCharm from JetBrains. IntelliJ is the best Java IDE; PyCharm is making my Python work a pleasure.
IMHO, not using IDE to develop is just like using typewriter to write a novel. Nobody said you can't, but why you have to try that hard when you already have laptop?
I code in Vim for python. If you want to use an IDE then I would recommend IntelliJ's PyCharm. I use vim because the actual editing is far superior and if you are a power user there is very little that you can't do easily.
PyCharm provides help with api by providing completion and helps with some basic refactoring. These advantages though wear of sooner than you would expect. I use grep and vim regex to do refactoring - its a bit more work than pycharm but if you can manage it then the advantages of vim clearly outweigh using an ide.
I assume that you are developing in a *nix environment, if you use windows then I would recommend using an Ide.
As opposed to some other guys here, I think that an IDE does add much to software development, even for a dynamically typed language like Python which makes it harder to do static analysis.
My preferred IDE for Python development is Eclipse with PyDev. Before that, I coded in Notepad++ which isn't much different than the PyDev editor in terms of features. PyDev has some great features that you won't find in a "normal" editor:
It shows warnings and syntax errors (almost) in realtime. A text editor won't tell me about typos, but PyDev does. As another example, unresolved imports or undefined functions (e.g. because of a typo) are marked as warnings/errors. And there are many more common mistakes that are automatically detected, and PyDev can be integrated with pylint so that warnings and errors from pylint are displayed with the usual icons in the editor.
Autocompletion by introspection
Outline view of the current module and its classes
Additionally, Eclipse itself is also great for any kind of programming project. I especially like the fully integrated interface - project explorer, editor, outline, console, problems overview, run configurations and so on. When using Vim, Emacs or similar, I guess you would have to install lots of plugins or custom scripts to achieve the same.
As you said you want to do a project, I think that Eclipse is a good choice. For quickly hacking a small Python script, it's overkill of course.
If you just start learning python/glade/gtk stack, I'd say you should start without an IDE just to learn how it works internally. This will help you later when your code will be bigger and more complex.
However, good IDE helps in so many ways I wouldn't recommend against using any in the long run. This article might help you decide whether you need any: http://infoworld.com/d/developer-world/infoworld-review-nine-fine-python-development-tools-374
it's horses for courses, personally i'm much happier with textmate or vim and a nice cup of coffee but it's what feels more comfortable to you.
there's no shame in using an IDE, if it's what gets your idea out there to the masses the most productive then use whatever you like.
however when starting out i'd favour something with intellisense as it'll teach you the basics as you type, give it a year and you'll be a master at it.
Two ways to approach this:
Use what you're used to. If you have used an editor in the past and know its quirks, stick with it. You'll waste less time figuring out how to work with the tool and spend more time on the actual project.
Use something new. Anjuta, vim, whatever, as long as you haven't spent too much time with it so far. You'll learn a whole lot of stuff besides your actual project, but the project itself won't be done as fast as could be.
Personally, I prefer 2. Always learn something new, as long as it's not crunch time and it-has-to-be-done-by-friday. An IDE can help you only so much, but when you're still in the learning phase the more time you spend on the code yourself, the better.
I'm not a Python programmer, but I prefer not to use IDEs.
The reason for this is that I find IDEs are often big and do too many things for me, whereas using Notepad++ and the command prompt allows me to trim things down to suit my needs rather than being surrounded by features that I don't use. This allows me to learn more easily, because I have more control over what happens.
Don't learn coding with an IDE. Code with it!
I find using an IDE to dramatically help my Python code productivity. In particular, using wingide makes coding in python a pleasure. It has all the normal things you would expect (syntax highlighting, auto-complete, etc) but the killer features are the debugger and the debug probe.
These two features are worth the cost of the program. It lets you see the live state of the application and try out python statements live at breakpoints. I find this especially helpful to explore the current state and to try out some code to see if it will work. I often write some of the trickier sections of code in the debug probe live and them copy them into my application. Very nice.
I'm new to Python, with a background in statically typed languages including lots and lots of Java.
I decided on PyDev in eclipse as an IDE after checking features/popularity etc.
I was stunned that auto-complete doesn't seem to work properly for builtins. For example if I try automcomplete on datafile after:
datafile = open(directory+"/"+account, 'r')
datafile.
No useful methods are suggested (e.g. realines). Only things like call.
I am used to learning a language by jumping into class definitions and using lots of auto-complete to quickly view what a class will do. My PyDev 'interpreter' is set up fine with 'forced builtins'.
Is it possible to get auto-complete for builtins with PyDev? Am I approaching the IDE wrong, i.e. should have an interpreter running on the side and test stuff with it? So far the IDEs have seemed weak, e.g. IDLE segfaulted on my new mac after 2 minutes. I'd love to know what experienced Python developers do when exploring unfamiliar (builtin) modules, as this is making me reconsider my initial attraction to Python. I like a language you can learn by easy exploration!
Thanks,
In my opinion, the Python shell is a much better place to explore new modules than relying on an IDE. Don't forget, in Python you can do anything in the shell that you can do in a program, because there's no separate compilation step. And in the shell, you can use dir(x) to find all the properties and methods of x, whether x is a module, a class, or whatever.
Even better, the enhanced iPython shell does provide tab completion for all objects.
In fact because of this, many Python programmers - myself included - don't use an IDE at all, but just a simple text editor (I use VIM).
Just to keep it up to date so that new readers are not confused about the current state of Pydev - the example you gave now works in Pydev. (btw, one should avoid operating on paths manualy - use os.path.join instead)
I'd love to know what experienced
Python developers do when exploring
unfamiliar (builtin) modules
I use ipython. Ipython is an enhanced version of the interactive shell that adds tab completion and quick access to an object's doctstring. It also gives lots of other features that the standard shell does not have - you can find a summary of its features here.
Someone more knowledgeable here can give you a detailed answer. Here is a short one.
Autocomplete for a dynamically typed language can by nature never be as rich as that for a statically typed language. In the case of open for instance there is no way to figure out what will be the return type at the time of writing the code. The method signature does not include a return type unlike a statically typed language like Java. Consequently the IDE is not able to give you any hints.
You certainly should have an REPL running during any Python development. One advantage of an interpreted language is that you can test small chunks of your code on the REPL as you go along. It is also a good place to test your understanding of how built-ins and other modules work.
I work on Ubuntu so I do not know how easy or difficult it is to get IDLE running on a Mac. I usually work with the very handy iPython for REPL needs and use Pydev for other development (such as Django). You might want to give iPython a try.
You want IPython. As Daniel pointed out above, the interactive shell is a much better way to explore Python (and indeed, most other languages too).
This might help with setting it up on OSX.
You might want to take a look at WingIDE. It autocompletes your datafile correctly.
If it is unable to infer the type, you can use an assert like
assert isinstance(datafile, file)
to help the autocompleter out
I use PyDev at work so I know where you're coming from. If you're willing to consider other tools, have a look at JetBrains' PyCharm, that's my new preferred Python IDE for my own projects. No affiliation to speak of except to say I'll be picking it up when it's out of beta. :)
I recently started learning Python. Not yet ventured into coding.
During one of my learning sessions, i came accross the term Jython.
I googled it & got some information.
I would like to know if anyone has implemented any real-world program using Jython.
Most of the time, Jython isn't used directly to write full read-world programs, but a lot of programs actually embed Jython to use it as a scripting language.
The official Jython website gives a list of projects, some written in Jython, others using Jython for scripting:
http://wiki.python.org/jython/JythonUsers
I am writing a full application in Jython at the moment, and would highly recommend it. Having all of the Java libraries at your disposal is very handy, and the Python syntax and language features actually make using some of them easier than it is in Java (I'm mostly talking about Swing here).
Check out the chapter on GUI Applications from the Jython book. It does a lot of comparisons like 'Look at all this Java code, and now look at it reduced to Python code of half the length!'.
The only caveats I've found are:
Jython development tends to run slightly behind Python, which can be annoying if you find a cool way of doing something in Python, only to discover it's not supported in the current Jython version.
Occasionally you might have hiccups with the interface between Python and Java (I have a couple of unsolved problems here and here, although there are always workarounds for this kind of thing).
Distribution is not as simple as it could be, although once you figure out how to do it, it's fairly painless. I recommend following the method here. It essentially consists of:
Exploding jython.jar and adding your own modules into it.
Writing and compiling a small Java class that creates a Python interpreter and loads up your Python modules.
Creating an executable .jar file consisting of the jython.jar modules, your own Python modules, and the Java class.
Jython really shines for dependency injection.
You know those pesky variables you have to give your program, like
file system paths
server names
ports
Jython provides a really nice way of injecting those variables by putting them in a script. It works equally well for injecting java dependencies, as well.
WebSphere and WebLogic use it as their default scripting engine for administrative purposes.
A lot of other Oracle products ship it as part of their "oracle_commons" module (Oracle Universal Installer, Oracle HTTP Server etc). It's mostly version 2.2 being deployed though, which is a bit old and clunky.
There is a list of application that uses jython at http://wiki.python.org/jython/JythonUsers
I've got some experience with Bash, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using
the Windows command-line language. For some reason said language really irritates me, so I was considering learning Python and using that instead.
Is Python suitable for such things? Moving files around, creating scripts to do things like unzipping a backup and restoring a SQL database, etc.
Python is well suited for these tasks, and I would guess much easier to develop in and debug than Windows batch files.
The question is, I think, how easy and painless it is to ensure that all the computers that you have to run these scripts on, have Python installed.
Summary
Windows: no need to think, use Python.
Unix: quick or run-it-once scripts are for Bash, serious and/or long life time scripts are for Python.
The big talk
In a Windows environment, Python is definitely the best choice since cmd is crappy and PowerShell has not really settled yet. What's more Python can run on several platform so it's a better investment. Finally, Python has a huge set of library so you will almost never hit the "god-I-can't-do-that" wall. This is not true for cmd and PowerShell.
In a Linux environment, this is a bit different. A lot of one liners are shorter, faster, more efficient and often more readable in pure Bash. But if you know your quick and dirty script is going to stay around for a while or will need to be improved, go for Python since it's far easier to maintain and extend and you will be able to do most of the task you can do with GNU tools with the standard library. And if you can't, you can still call the command-line from a Python script.
And of course you can call Python from the shell using -c option:
python -c "for line in open('/etc/fstab') : print line"
Some more literature about Python used for system administration tasks:
The IBM lab point of view.
A nice example to compare bash and python to script report.
The basics.
The must-have book.
Sure, python is a pretty good choice for those tasks (I'm sure many will recommend PowerShell instead).
Here is a fine introduction from that point of view:
http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/
EDIT: About gnud's concern: http://www.portablepython.com/
Are you aware of PowerShell?
Anything is a good replacement for the Batch file system in windows. Perl, Python, Powershell are all good choices.
#BKB definitely has a valid concern. Here's a couple links you'll want to check if you run into any issues that can't be solved with the standard library:
Pywin32 is a package for working with low-level win32 APIs (advanced file system modifications, COM interfaces, etc.)
Tim Golden's Python page: he maintains a WMI wrapper package that builds off of Pywin32, but be sure to also check out his "Win32 How Do I" page for details on how to accomplish typical Windows tasks in Python.
Python is certainly well suited to that. If you're going down that road, you might also want to investigate SCons which is a build system itself built with Python. The cool thing is the build scripts are actually full-blown Python scripts themselves, so you can do anything in the build script that you could otherwise do in Python. It makes make look pretty anemic in comparison.
Upon rereading your question, I should note that SCons is more suited to building software projects than to writing system maintenance scripts. But I wouldn't hesitate to recommend Python to you in any case.
As a follow up, after some experimentation the thing I've found Python most useful for is any situation involving text manipulation (yourStringHere.replace(), regexes for more complex stuff) or testing some basic concept really quickly, which it is excellent for.
For stuff like SQL DB restore scripts I find I still usually just resort to batch files, as it's usually either something short enough that it actually takes more Python code to make the appropriate system calls or I can reuse snippets of code from other people reducing the writing time to just enough to tweak existing code to fit my needs.
As an addendum I would highly recommend IPython as a great interactive shell complete with tab completion and easy docstring access.
I've done a decent amount of scripting in both Linux/Unix and Windows environments, in Python, Perl, batch files, Bash, etc. My advice is that if it's possible, install Cygwin and use Bash (it sounds from your description like installing a scripting language or env isn't a problem?). You'll be more comfortable with that since the transition is minimal.
If that's not an option, then here's my take. Batch files are very kludgy and limited, but make a lot of sense for simple tasks like 'copy some files' or 'restart this service'. Python will be cleaner, easier to maintain, and much more powerful. However, the downside is that either you end up calling external applications from Python with subprocess, popen or similar. Otherwise, you end up writing a bunch more code to do things that are comparatively simple in batch files, like copying a folder full of files. A lot of this depends on what your scripts are doing. Text/string processing is going to be much cleaner in Python, for example.
Lastly, it's probably not an attractive alternative, but you might also consider VBScript as an alternative. I don't enjoy working with it as a language personally, but if portability is any kind of concern then it wins out by virtue of being available out of the box in any copy of Windows. Because of this I've found myself writing scripts that were unwieldy as batch files in VBScript instead, since I can't usually depend on Python or Perl or Bash being available on Windows.
Python, along with Pywin32, would be fine for Windows automation. However, VBScript or JScript used with the Windows Scripting Host works just as well, and requires nothing additional to install.
I've been using a lot of Windows Script Files lately. More powerful than batch scripts, and since it uses Windows scripting, there's nothing to install.
As much as I love python, I don't think it a good choice to replace basic windows batch scripts.
I can't see see someone having to import modules like sys, os or getopt to do basic things you can do with shell like call a program, check environment variable or an argument.
Also, in my experience, goto is much easier to understand to most sysadmins than a function call.