I have taken the dive to learn Python (currently only experience I have is HTML, CSS, JavaScript, jQuery) and I'm using Learn Python The Hard Way.<p>However, this has me using Python 2.7 and I know that this is the last of Python 2.x and Python is what I might need to know going forward.<p>Should I look somewhere else to learn (I've gotten just about halfway through LPTHW) or stick through this? I guess it depends how different they are and if it's worth learning Python 2.7 if I'll just be unlearning and relearning certain aspects.<p>What should I do?
I thought I was on Stack Overflow for a moment, because this question always seems to come up.<p><a href="http://stackoverflow.com/questions/5478518/python-2-or-python-3-which-should-i-begin-with" rel="nofollow">http://stackoverflow.com/questions/5478518/python-2-or-pytho...</a>
<a href="http://stackoverflow.com/questions/170921/to-learn-python-2-then-3-or-3-from-the-start" rel="nofollow">http://stackoverflow.com/questions/170921/to-learn-python-2-...</a>
<a href="http://stackoverflow.com/questions/1222782/should-i-start-with-python-3-0" rel="nofollow">http://stackoverflow.com/questions/1222782/should-i-start-wi...</a>
<a href="http://stackoverflow.com/questions/2090820/what-version-of-python-should-i-use-if-im-a-new-to-python" rel="nofollow">http://stackoverflow.com/questions/2090820/what-version-of-p...</a>
Stick with Python 2.7 at the moment; there are many reasons for this which I will not go into. But, later on if the community/if you decide to switch more towards Python 3, then you will not be 'unlearning' much.<p>I recommend LPtHW and then Dive into Python. After going through those two books you will have a really goo grasp on the Python Programming Language. After which start coding and (possibly) get involved in some Python-based open source project (or at least study the code a bit).
Thanks for all the replies everyone! It definitely seems like it'd be worthwhile just going through and learning 2.7 then and using related libraries to create what I want (once I've learned and am able to do so).<p>However, this has me thinking. It seems like Ruby (and related frameworks, like Rails) don't have the backwards-compatibility issue that is seemingly plaguing Python?<p>The newest version of Ruby was easily adopted (compared to Python 3) as it remained backwards-compatible. Even upon researching the next evolution of Ruby (2), it seems that it won't be huge leap and, again, will remain backwards-compatible.<p>My question is... if I'm looking to start building a website now and use Python 2.7 (and likely Django), what would I do when the time comes and Python 3 is really the go-to version?<p>Would I need to rewrite the code entirely? Will the older code ever become compatible or easily transitioned?<p>It seems like Ruby would be the better choice to avoid possible fragmentation issues?<p>I could be entirely wrong here though. So, please, if someone could help me with this, that would be great. I went through some of Learn Ruby the Hard Way. And I'm willing to switch over to Ruby.<p>I like them both in different ways in terms of syntax/readability. But I don't know enough to really make a decision beyond that.<p>But this Python fragmentation between 2 and 3 makes me worried. I'd feel safer choosing to learn Ruby. I don't know though.
Keep going. Until the important libraries catch up, you should be using 2.7 for doing most projects at the moment. You won't have wasted much learning in the mean time.<p>Happy New Year.
From Learn Python The Hard Way:
<a href="http://learnpythonthehardway.org/book/ex0.html" rel="nofollow">http://learnpythonthehardway.org/book/ex0.html</a><p>A programmer may try to get you to install Python 3 and learn that. You should tell them, "When all of the python code on your computer is Python 3, then I'll try to learn it." That should keep them busy for about 10 years.
Is the goal here to learn how to write code in Python or to learn the specifics of each version of the language? If the goal is to just learn Python, I don't think it really matters which version you learn since the general basics of the language are pretty much the same between versions. In other words, a for loop is still a for loop.<p>Asking Google came up with this link: <a href="http://wiki.python.org/moin/Python2orPython3" rel="nofollow">http://wiki.python.org/moin/Python2orPython3</a><p>I'd personally start with 2.x so that you can understand the history of Python and then make sure to have an understanding of what is changing in 3 via links like this: <a href="http://docs.python.org/py3k/whatsnew/3.0.html" rel="nofollow">http://docs.python.org/py3k/whatsnew/3.0.html</a><p>Finally, if this is for a job, I guess one thing would be to see what the requirements of the job are. If you need to use Python 3 for your job, your best bet is probably to learn Python 3. =)
The difference between 2.7 and 3 is, to be honest, nothing big in terms of programming. I use both mostly without noticing the difference, because some libraries are still on old versions. For now, use import __future__ to help ease the transition and don't stress.
If your code heavily uses unicode texts, it will be easier to start with python 3, because all the iterators word on wide-chars instead of byte ones, and you don't have do some magic to handle them properly.
2.7 if you want to release anything AND consume other libraries. 3 if you never intend on using other than a learning exercise or will write everything from scratch.
What versions of python are on your machine?<p>My MBP (leopard -> snow leopard -> lion) has python versions 2.5, 2.6, and 2.7 (and there's a nice way to change the default python version). I fully suspect python3 is not there by default.
New projects should go with Python 3, if possible. But really, the two languages are not very far apart. Do whichever if you are just learning and want to make small temporary things.