Python -- editor advice, tools, etc.

Status
Not open for further replies.

Acert93

Ars Scholae Palatinae
1,317
I am a coding newb. My background is relatively limited: a CS class in high school (Pascal) nearly two decades ago and in the last decade moderate tinkering with XHTML/CSS/PHP/MySQL. In the last 5 years I have touched very little code. My 9 year old has shown a keen interest in learning to program. He reads very well and has strong math skills and has always had an interest in coding and he recently started the Python tutorial on CodeAcademy.

So I need advice.

My dad (sys admin) recommend Python and after reading around the last couple years and fiddling with it I think it is a solid suggestion. In fact I actually like Python a lot (something I cannot say about the other languages). I like it enough that after I started the CodeAcademy course (to get ahead of my son so I could tutor) that I have kept going as I find it exceedingly enjoyable--I just love the syntax and as I understand many of the programming concepts I find it exceptionally easy to quickly write a lot of functional code that WORKS the first time (and I can then show my wife the code and run her through it line-by-line and it even makes sense to her). This should be a fun adventure for us, but I digress.

So the questions...

# What version of Python? 2.x or 3.x? I was befuddled, to day the least, with the change of print from a statement to a function (print "" vs. print("")).

# What is a free, good, clean editor that is simple enough to not be obtrusive at first but we can grow into? I have seen quite a few recommendations for Eclipse + PyDev and Komodo Edit. There are sooo many editors so a recommendation of a couple of the best for our needs to test out would be fantastic!

# Best resources for beginners? References, guides, tutorials, books, etc. What essential links should I be aware of?

# Is there a better introduction than the CodeAcademy?

# What is a good tool after completing the CodeAcademy?

# Any animated objections to starting with Python instead of Javascript or Ruby?

# Anyone with experience with the Mindstorms Python mod? Is it worth trying or should we steer clear? (Mindstorms were planned to be the first introduction to programming but my son shows no interest in waiting to get an EV3 this fall--he wants to start now!)

# Yea or Nay? I have seen a lot of recommendations to have a fun project in mind while learning a language as it offers a bridge to taking your lessons and then putting them into practice in problem solving without immediate guidance to the best solution. I thought this was a good idea. My son really, really wants to make a game so and I have outlined a "graded" project to build a text based "baseball" game that each element slowly builds on the next (first task is a single multiple choice pitching/batting duo, second would be creating an inning, the next would be a full game, etc.) Is this a bad idea/too ambitious or does this sound like a good idea?

# GUIs and mobile? Any general nudging one way or another to lead to the best GUI and/or approach to using Python for mobile apps? Obviously not a concern right now but it would be nice if our learning path naturally built toward using an accessible, performant, flexible GUI and the ability to deploy to mobile platforms. (How many posts before someone says, "Yes JAVASCRIPT!")

# Best practices. I am aware having a parent, with nominal programming background, teaching children could lead to some bad practices and habits. Is there a 10 commandments of "Bad practices to avoid" or a good set of articles for me to review?

# What question(s) should I be asking that I am not?
 
I'm a professional Python developer.

# What version of Python? 2.x or 3.x?

Always go with the newest version that is reasonable for your environment. If you're using Linux, just go with the built-in version (or whatever has native packages) unless you need something specific. That's why we're on 2.7.

Never, ever treat print as a statement. There's no good reason to.

# What is a free, good, clean editor that is simple enough to not be obtrusive at first but we can grow into?

Again, what's your dev platform?
I use Emacs quite a bit for editing small stuff and for convenience. I never liked PyDev. I've bought WingIDE and PyCharm. Currently, I'm doing Django development, which means editing HTML, CSS, and JS. WingIDE has lousy support for non-Python languages, so I pretty much use PyCharm exclusively for our projects, but it's not free, depending on your use case. JetBrains does provide free licenses under some generous terms. If your serious about getting into Python, it wouldn't be a bad idea to purchase a personal license. You shouldn't have any problems using a single license for you and your family.

What are you looking for in an your editor? At a minimum, an editor needs to support intelligent indentation.

Jumping into a complex editor can be an additional burden if you're not don't need the complexity. Learning an advanced IDE or even editor can be difficult for new users. I like Emacs because it allows simple text editing to quite featureful IDE, and the user is left to completely decide how complex she wants it be. You really only need to learn about six keyboard shortcuts to use Emacs effectively, and the same goes for Vim.

I think the base (again for Linux systems) is ipython and either vim (not much experience) or Emacs. I would do the same on Mac. No experience developing on Windows.

# Best resources for beginners?
Resources is vague and encompasses all kinds of things. I regularly read reddit.com/r/python and subscribe to Pycoders to stay current on the Python community. For actually learning Python, I haven't done that in years. Learn Python the Hard Way is great. I also like Learning Python by Mark Lutz if you want a book.

My son really, really wants to make a game
User interfaces, even text-based, tend to be complicated. I'm not sure I'd recommend starting here. A new user will intuitively just try to get shit done, which doesn't lend itself towards good design.

that each element slowly builds on the next (first task is a single multiple choice pitching/batting duo, second would be creating an inning, the next would be a full game, etc.) Is this a bad idea/too ambitious or does this sound like a good idea?

I think that it is very difficult for a completely new programmer to do this. I would instead start with simple, standalone exercises to build familiarity with the language and programming in general.

The problem is that you have to start so simple at beginning that none of the work is reusable. For example, a function will be complex and difficult at first. However, those first functions likely won't fit into the larger project whatsoever. It can be frustrating to rebuild substantial portions at the beginning.

You may want to start with the easy exercises on reddit.com/r/dailyprogrammer/. Someone with some aptitude shouldn't be spending more than an hour on an exercise at the beginning. They provide sample input, output, and clear instructions what the exercise is. Even talking through the problems without writing code will teach someone how to think like a programmer. Larger projects don't have that clear set of goals or digestible steps.

# Any animated objections to starting with Python instead of Javascript or Ruby?
You'll find general agreement here that Python is the preferred starting language.

# Best practices.
Follow PEP8.

I think the best approach is to start with utility scripts and generally simple stuff. Get your feet wet actually writing some stuff. Then, read something like Learning Python, which is a 1000 page book. If you go into that book with the ability to write Python, you have a much better time. First, you'll fly through the book because many concepts are completely familiar. Second, you'll be able to relate many of the lessons to things you've done and have a chance to compare how you did things to a Lutz's solid style.

Your best bet on teaching someone else concurrently is to stay a couple of steps ahead.
 
I also love JetBrains (as a professional Python developer), but it tends to be expensive as a start up cost, and python doesn't really need it in the same way that I'd say something like Java needs an IDE. If you're just looking to get off the ground, sometimes simpler is better and I've recommended Sublime Text 2 enough in the past to see it come to some fruition. ST2 is also cross-platform and basically free (nagware) and will format Python files by default, though it doesn't do much more than that.

++ for Learn Python the Hard Way

Don't teach your kid JS first. Seriously. I personally prefer Ruby over Python for a handful of reasons that are really minor, and I think I'm probably the strongest pro-Ruby opinion holder around these parts, so I don't think you'll see anyone arguing for moving to Ruby.

On the what to learn front: games are hard to program. UIs are difficult, but they can also be a great starting point. I'd recommend working through LPTHW, and by the time you get to the end of that book, one of the last exercises is starting to create a small text-based game. There's enough there to start building from at that point.
 

w00key

Ars Legatus Legionis
10,099
Subscriptor
If you need a free IDE, just download PyDev.

After the last patch, the PyDev vs PyCharm comparison is:


In favor of PyDev:

- Versioning system integration in Eclipse is much nicer
- Free (vs $99-200)
- Has auto completion with type inference
- Manual type hinting via assert isinstance(object, Type) or @type/@rtype in docstring
- Much faster on Windows (native components)
- Automatic type inference is better than PyCharm's. Understands way more package's structure, ex.: lxml, which PyCharm doesn't understand at all.
- Can set grammar version per project for validation, even if your local Python version is newer. This is nice if you have projects deployed on 2.6 that you cannot upgrade yet. PyCharm keeps suggesting using set literals, this gets old quick.


In favor of PyCharm

- Has auto completion with type inference
- Manual type hinting is even better than PyDev, supports basic generics, like @type param1: list of int
- Faster on OSX/Linux? (From what I've heard. Eclipse/SWT native components don't work too well there?)


The main reason we're sticking to PyCharm for now is the "list of int" / "dict from int to string" type specifier for type hinting, we use it extensively and it's a must have for larger projects. Having used both for a long time (years for PyDev, ~1 year for PyCharm), I prefer Eclipse+PyDev over PyCharm.
 

Alamout

Ars Legatus Legionis
27,285
If you're starting with Learn Python the Hard Way, I don't think an IDE is necessary (and in fact I think he specifically says not to use one). Once you've gone through that book you can start thinking about real IDEs.

A smart-ish text editor (i.e. one that indents correctly) would be sufficient. A barebones IDE would be more than enough. I'm not sure what would be a good option on Windows, but many IDE makers distribute a free version that should work.
 

Acert93

Ars Scholae Palatinae
1,317
[url=http:/civis/viewtopic.php?p=25162311#p25162311:3f90mhjy said:
Alamout[/url]":3f90mhjy]If you're starting with Learn Python the Hard Way, I don't think an IDE is necessary (and in fact I think he specifically says not to use one). Once you've gone through that book you can start thinking about real IDEs.

A smart-ish text editor (i.e. one that indents correctly) would be sufficient. A barebones IDE would be more than enough. I'm not sure what would be a good option on Windows, but many IDE makers distribute a free version that should work.

He does note that and recommends Notepad++ for the editor. I picked up Notepad++ and it is quite nice and assists with a lot of the basics (like indenting). He recommends skipping IDLE and running everything from the Windows PowerShell. Seems like reasonable approaches for a beginner. I do need to go back and install Python 2.7 as I installed 3.

Thanks for all the advice. I have this page bookmarked to look at PyDev and iPython down the road. iPython looks very interesting... I am honestly tempted to use it but I don't want to make things too complicated starting out. We had fun this morning using a code side cookbook and looking at the code and seeing how it runs.
 

w00key

Ars Legatus Legionis
10,099
Subscriptor
+10000 for IPython. It's not that complicated. After installation, you can just use ipython-script.py (should be in the PATH, if not, add Python27\scripts) to get an interactive shell.


For example, when doing http://learnpythonthehardway.org/book/ex3.html, instead of creating a file, you can just enter the commands and explore

awoi9i0.png



At [9], I typed f. and press [tab] for auto completion. This is insanely useful for exploring the API and what you can do with objects.


Installation (win32):
  1. (pre-req: PIP) download https://raw.github.com/pypa/pip/master/ ... get-pip.py and run it.
  2. Then run the command pip install pyreadline ipython

For Debian, apt-get install python-pip, then pip install --upgrade pip; pip install ipython.
 

norton_I

Ars Tribunus Angusticlavius
6,171
Subscriptor++
I am a big fan of notepad++ with ipython-qtconsole.

Python 3 has some nice improvements, but there are still a lot of 3rd party modules that don't work with it, like twisted. Python 2.7 is still the safe bet, but go ahead and read a bit about the differences so you can make the transition easy if you ever need to do so. For instance, always use new style classes, and use future directives to set things like division and print statements to reflect the new behavior.
 

drogin

Ars Tribunus Angusticlavius
8,283
Subscriptor++
Another vote for Sublime Text 2.

It is a seriously good editor and it can be used for pretty much anything.

You really want to learn the short cuts to maximize your productivity (which is true of any editor/IDE), and learn how the package system works.

It is quite extensible and at a great price point.

The fact that the license works cross platform is another big bonus because you just have to learn one editor and can be effective across any OS you may use.
 
[url=http:/civis/viewtopic.php?p=25193285#p25193285:a8dui12d said:
w00key[/url]":a8dui12d]
[url=http:/civis/viewtopic.php?p=25193221#p25193221:a8dui12d said:
Chord[/url]":a8dui12d]Pytools

http://pytools.codeplex.com/

Shiny. Anyone with real world experience with that? The site is a huge list of video's, no one has time for that - what matters to me is: how well does intellisense work in PTVS?

Not sure I just found it myself a few days ago. it's installed but hasn't been used yet.
 
I'd stay away from Eclipse simply because Eclipse is this huge complicated beast of a program and gets in the way of programming if you don't what everything does.

I like Sublime Text but almost any text editor and a shell will work well.

I've personally used PyGame and was able to go from zero to a 2D game in under 30 hours of actual work. However, I have a decent amount of programming familiarity. PyGame by nature also kind of encourages bad code since all of the examples are not really modular and rely on a lot of globals.

Still, you can get up and running on a few lines of code in PyGame so it might be a nice "advanced" project to start on later once you're past some of the basics of data structures. I haven't really distilled all of the concepts you need for doing a good job in PyGame but you would need to understand, for sure, static variables (vs. instance variables), for and while loops, inheritance, and be comfortable with global state. then you'll want to get up to speed quickly on event loops, which most introductory programming texts don't talk about.

Game dev is really fun and it is a great way to hammer in the importance of mathematics and trig and geometry, since you need all of those for making interesting games.
 

dmitriyk

Ars Tribunus Angusticlavius
8,804
[url=http:/civis/viewtopic.php?p=25160847#p25160847:3jebmodx said:
herko[/url]":3jebmodx]If you need an IDE, PyCharm. There simply is no other.
Eh, technically speaking, IntelliJ IDEA with the free Python plugin is a superset of PyCharm, so there's also that option if you need an IDE for other languages. The personal license, however, is $180; PyCharm is $100.
 

herko

Tone down Your Control issues.
7,012
Moderator
[url=http:/civis/viewtopic.php?p=25213409#p25213409:3fdadm49 said:
dmitriyk[/url]":3fdadm49]
[url=http:/civis/viewtopic.php?p=25160847#p25160847:3fdadm49 said:
herko[/url]":3fdadm49]If you need an IDE, PyCharm. There simply is no other.
Eh, technically speaking, IntelliJ IDEA with the free Python plugin is a superset of PyCharm, so there's also that option if you need an IDE for other languages. The personal license, however, is $180; PyCharm is $100.

Nitpicker :p
 

herko

Tone down Your Control issues.
7,012
Moderator
[url=http:/civis/viewtopic.php?p=25245413#p25245413:l0zhtl8c said:
dmitriyk[/url]":l0zhtl8c]I've tried (tried; not really used) both and they seemed to be identical.

PyCharm literally is IDEA with the Python plugin, minus the ability to run other language-specific IDEA plugins. In other words, you can't turn PyCharm into "full" IDEA. That's what makes it cheaper.

Sometimes features debut first in PyCharm and then get picked up by IDEA, but they are the same codebase, and (given the same version of IDEA and plugin) behave exactly the same.
 

w00key

Ars Legatus Legionis
10,099
Subscriptor
If it's for teaching, showing them how to use an open source/free editor would be better as you don't force students who want to play more with it to buy or TPB software.

Even at uni, I preferred legal and free stuff over the propitiatory stuff, I mean, it's nice that you showed me Rational Rose but there's no way I'm going to pay for that. The Netbeans (Swing) / Eclipse (CDT) demos were much more useful.
 

Rubel

Ars Scholae Palatinae
857
[url=http:/civis/viewtopic.php?p=25253547#p25253547:ftyaw5mw said:
w00key[/url]":ftyaw5mw]If it's for teaching, showing them how to use an open source/free editor would be better as you don't force students who want to play more with it to buy or TPB software.

Even at uni, I preferred legal and free stuff over the propitiatory stuff, I mean, it's nice that you showed me Rational Rose but there's no way I'm going to pay for that. The Netbeans (Swing) / Eclipse (CDT) demos were much more useful.

I see your point, although as these folks are going to be students for some time, the $29 student price for PyCharm (much lower than the $99 for IDEA) might be something they can swing.

However, maybe something like http://portablepython.com/ would be a better introduction to the totally free stuff out there.
 

Rubel

Ars Scholae Palatinae
857
[url=http:/civis/viewtopic.php?p=25266475#p25266475:unw9y4m5 said:
wallinbl[/url]":unw9y4m5]For teaching, ipython notebooks are actually really cool.

The mix of Markdown and lines of code looks like it might be useful and expressive for lessons. Do you have any examples you could share? I'll dig into it more myself, too...thanks.

It's nice we have multiple solid options to learn more Python.
 

wallinbl

Ars Legatus Legionis
14,319
Subscriptor
[url=http:/civis/viewtopic.php?p=25269291#p25269291:2yhrdjve said:
Rubel[/url]":2yhrdjve]
[url=http:/civis/viewtopic.php?p=25266475#p25266475:2yhrdjve said:
wallinbl[/url]":2yhrdjve]For teaching, ipython notebooks are actually really cool.

The mix of Markdown and lines of code looks like it might be useful and expressive for lessons. Do you have any examples you could share? I'll dig into it more myself, too...thanks.

It's nice we have multiple solid options to learn more Python.
This Data Science class at Harvard uses it (some examples are available):
http://www.cs109.org/homework/homework.php
 
[url=http:/civis/viewtopic.php?p=25265851#p25265851:2jsdae27 said:
Rubel[/url]":2jsdae27]I see your point, although as these folks are going to be students for some time, the $29 student price for PyCharm (much lower than the $99 for IDEA) might be something they can swing.

I might have been a poor or a cheap child, but unless I thought programming was the totally awesome amazing shizzle, I wouldn't have spent $29 on something like that. I mean, why do that when Notepad seems to do something similar and is included in Microsoft Windows for free? (sarcasm, of course)

I mean $29 is an entire two movies, or one Nintendo 3DS game, or a Twilight Blu-Ray combo pack!
 

herko

Tone down Your Control issues.
7,012
Moderator
[url=http:/civis/viewtopic.php?p=25274825#p25274825:3f16i41p said:
EmeraldArcana[/url]":3f16i41p]
[url=http:/civis/viewtopic.php?p=25265851#p25265851:3f16i41p said:
Rubel[/url]":3f16i41p]I see your point, although as these folks are going to be students for some time, the $29 student price for PyCharm (much lower than the $99 for IDEA) might be something they can swing.

I might have been a poor or a cheap child, but unless I thought programming was the totally awesome amazing shizzle, I wouldn't have spent $29 on something like that. I mean, why do that when Notepad seems to do something similar and is included in Microsoft Windows for free? (sarcasm, of course)

I mean $29 is an entire two movies, or one Nintendo 3DS game, or a Twilight Blu-Ray combo pack!

As a kid, I saved for months and months and then begged and pleaded for someone who was coming to the US to buy me a copy of Delphi 1.0. Yes, the programming language.

It was awesome.
 

Alamout

Ars Legatus Legionis
27,285
[url=http:/civis/viewtopic.php?p=25274825#p25274825:tl1plk6l said:
EmeraldArcana[/url]":tl1plk6l]I might have been a poor or a cheap child, but unless I thought programming was the totally awesome amazing shizzle, I wouldn't have spent $29 on something like that. I mean, why do that when Notepad seems to do something similar and is included in Microsoft Windows for free? (sarcasm, of course)

I mean $29 is an entire two movies, or one Nintendo 3DS game, or a Twilight Blu-Ray combo pack!
Depends what kind of students we're talking about here--high school, college, graduate, etc. Most people are not going to spring for an IDE after a single programming class. But if they're expecting to do a lot of programming then it's no different from buying a calculator or a textbook (except it's much cheaper).

Like any tool, you can amortize its utility over how much you use it or how much time it saves you. If you're going to do a significant amount of programming, $29 is well worth the investment in your own time.
 
EmeraldArcanawrote:
I mean, why do that when Notepad seems to do something similar and is included in Microsoft Windows for free? (sarcasm, of course)

;)

Notepad++ is free and kicks Notepad's ASCII all over the memory map. Once a person learns the language and outgrows a editor, then start shopping for fancy GUI development suite.

(Regular Notepad isn't an editor, at most it's digital scratch paper.)
 

Sunner

Ars Praefectus
4,992
Subscriptor++
While on the topic, since PyCharms seems to be all around adored I figured I'd give it a go, except all my work boxes are Linux. The problem is, to be blunt, performance is utter shit. I'm used to font rendering being wonky so that was easy enough to fix, but I haven't ran into a Java GUI app this slow since I ran SMC on some old SPARC box back in early 2000. I mucked about a bit with Xmm/Xms since my boxes have plenty of memory but to no avail.
I also tried some different JDK's, Oracle 1.7, OpenJDK 1.7 and 1.8, same deal either way.
There's nothing in particular that's slow by the way, the entire UI is just all around sluggish, menus, clicking boxes, even typing.

Anyone ran into and maybe even fixed this? My Google fu is weak and only brought me complaints about font rendering. This is both Fedora 19 and RHEL 6 by the way, 64-bit both. The boxes are Xeon/Corei7's or higher and plenty of RAM so no slouches, the weakest link by far being the graphics cards(the shitty nVidia Quadros, I don't recall the exact names but basically the ones that are glorified 2D cards, not that it should matter).
 
[url=http:/civis/viewtopic.php?p=25336831#p25336831:33k86axs said:
Sunner[/url]":33k86axs]While on the topic, since PyCharms seems to be all around adored I figured I'd give it a go, except all my work boxes are Linux. The problem is, to be blunt, performance is utter shit. I'm used to font rendering being wonky so that was easy enough to fix, but I haven't ran into a Java GUI app this slow since I ran SMC on some old SPARC box back in early 2000. I mucked about a bit with Xmm/Xms since my boxes have plenty of memory but to no avail.
I also tried some different JDK's, Oracle 1.7, OpenJDK 1.7 and 1.8, same deal either way.
There's nothing in particular that's slow by the way, the entire UI is just all around sluggish, menus, clicking boxes, even typing.

Anyone ran into and maybe even fixed this? My Google fu is weak and only brought me complaints about font rendering. This is both Fedora 19 and RHEL 6 by the way, 64-bit both. The boxes are Xeon/Corei7's or higher and plenty of RAM so no slouches, the weakest link by far being the graphics cards(the shitty nVidia Quadros, I don't recall the exact names but basically the ones that are glorified 2D cards, not that it should matter).

That's interesting.

I run Pycharm on Linux, specifically Fedora 19 with OpenJDK. I even edited out the stupid OpenJDK performance warning because I didn't have any problems.

Could you provide some additional information about your platform? Distro and version should be sufficient if it's popular. Graphics and CPU would be helpful, too.
I missed the last part of your post.

Run htop with Pycharm and see if there are CPU spikes. That's the only thing that it could be. I'm leaning towards graphics problems. Are you using the Nvidia driver or default Nouveau in Fedora?

lspci will tell you the GPU model.
 
Status
Not open for further replies.