• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Python v2 v v3 - Which to start using

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Python v2 v v3 - Which to start using

    Having dabbled with python in the past and taken little notice of the version, I am now aiming to beef up my expertise so I can justly include perl and python guruship on my CV.

    Also, as luck would have it, clientco have given their blessing to me working with python scripts as a background task, as their long-term aim is to evolve away from perl to python. (I reckon this will never happen, but there you go.)

    Reading tutorials etc, and the python homepage, the first thing that becomes apparent is that there are two major versions in use v2 (currently 2.7.10) and v3 (currently 3.5.0).

    My strong inclination is to assume v2 is old hat, kept around merely for backward compatibility, and v3 is obviously the one to go for. But that would be wrong if the situation is like perl, for which v5 is used almost exclusively and v6 is no more than an uber-techie's toy that has been "on the horizon" for more than ten years and will obviously never be widely used having been overtaken by events (not least by python).

    So, what do python gurus reading this think? Is v3 fairly stable and the correct choice (a) on a greenfield system (python wise) or even (b) if there are python scripts already in use? How incompatible are they?

    TIA
    Work in the public sector? Read the IR35 FAQ here

    #2
    Originally posted by OwlHoot View Post
    Having dabbled with python in the past and taken little notice of the version, I am now aiming to beef up my expertise so I can justly include perl and python guruship on my CV.

    Also, as luck would have it, clientco have given their blessing to me working with python scripts as a background task, as their long-term aim is to evolve away from perl to python. (I reckon this will never happen, but there you go.)

    Reading tutorials etc, and the python homepage, the first thing that becomes apparent is that there are two major versions in use v2 (currently 2.7.10) and v3 (currently 3.5.0).

    My strong inclination is to assume v2 is old hat, kept around merely for backward compatibility, and v3 is obviously the one to go for. But that would be wrong if the situation is like perl, for which v5 is used almost exclusively and v6 is no more than an uber-techie's toy that has been "on the horizon" for more than ten years and will obviously never be widely used having been overtaken by events (not least by python).

    So, what do python gurus reading this think? Is v3 fairly stable and the correct choice (a) on a greenfield system (python wise) or even (b) if there are python scripts already in use? How incompatible are they?

    TIA
    Not a guru - but I get the impression that v3 exists to address some significant design flaws in v2. So for that reason I went with 3 because I don't thinks it's just extra fluff - it seems like it's the way forward for new stuff.

    And from the looks of it it doesn't look too hard to learn the differences when I have to work with older v2 code.

    Comment


      #3
      When looked at Python a couple of years or so ago the general wisdom was to stick with 2 because 3 wasn't ready yet, and a lot of packages were still on 2.

      Revisiting it lately I see that a lot of stuff has made the transition to 3, and some packages now have that as a requirement, so I'm giving it a whirl for new stuff. I haven't come across any show stoppers yet, and hopefully I can avoid stuff which still has a fixed V2 dependency.
      Behold the warranty -- the bold print giveth and the fine print taketh away.

      Comment


        #4
        I've been working on integrating Python in an application and I initially did it with v3 because the latest is obviously the best. But I found googling for how to do things was finding v2.7 answers 99% of the time, plus I do need to support some legacy scripts that were done in v2. So I did it again with the latest 2.7 which meant some changes to the C++ as the API is a little difference and some subtle changes to the script.

        I don't think the language is different enough to worry about which you learn, but it seems v2 is the one that's still mostly in use.

        Oh and Python sucks. Hateful language.
        Will work inside IR35. Or for food.

        Comment


          #5
          Both will work but you should default to 3 unless you have a reason not to.

          Comment


            #6
            Originally posted by VectraMan View Post
            Oh and Python sucks. Hateful language.
            Python specifically ? or the dynamic typing?

            Comment


              #7
              Integer arithmetic has changed

              Python 2 must be the only language I've come across where integer arithmetic rounds down to minus-infinity rather than zero.

              Code:
              V2:
              
              >>> 7 / 3
              2
              >>> 7 / -3
              -3
              >>>
              In V3, the results of integer arithmetic default to float instead.

              Code:
              >>> 7 / 3
              2.3333333333333335
              >>> 7 / -3
              -2.3333333333333335
              >>>
              Behold the warranty -- the bold print giveth and the fine print taketh away.

              Comment


                #8
                Originally posted by SpontaneousOrder View Post
                Python specifically ? or the dynamic typing?
                Well the dynamic typing is a problem, as it is in all scripting languages if you're going beyond a trivial program. Half the problem with that is that the API docs don't tell you what types any of the function parameters want.

                But it has no proper for loops, no switch; you have to write True, False, None (with a capital) inconsistent with everything else in the language. It uses and, or, not for logic like it's bloody BASIC; you have to explicitly put in "self" as a parameter to member functions; there's the __init__ nonsense which looks like a kludge that accidentally got left in; there aren't brackets where there should be and then there's the stupid whitespace being significant thing. I admit it's because I've spent 20 odd years looking at C++, but I find it very hard to see the blocks of code without curly brackets.

                The aforementioned integer division returning a float caught me out too. WTF?

                I'd much prefer to use Javascript, though obviously that has more than a few issues too.
                Will work inside IR35. Or for food.

                Comment


                  #9
                  Originally posted by VectraMan View Post
                  Oh and Python sucks. Hateful language.
                  I tend to agree, especially the significant whitespace thing, which seems a massive retrograde step back to punched card days.

                  But I've long since stopped worrying about technical issues like that, and now judge a language or IT skill only in so far as it facilitates finding contracts.

                  Thanks for the replies guys. I've decided to go with python 3, and am studying the Language Reference and Standard Library.
                  Work in the public sector? Read the IR35 FAQ here

                  Comment

                  Working...
                  X