• deur@feddit.nl
      link
      fedilink
      arrow-up
      5
      arrow-down
      1
      ·
      11 months ago

      Any dev who pretends Python 2 doesn’t exist should probably look around a bit more. Damn legacy code.

      • jeremyparker@programming.dev
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        11 months ago

        Seconding this. For someone that doesn’t know anything about Python, there are vital aspects of Python 2 that need to be covered.

        In the context of learning a language, most of the time, a lower version number doesn’t mean that much. In the case of Python 2, there are fundamental incompatibilities - and, as you say, it’s still out there, and when your see it, you need to know what that means.

        Maybe you don’t choose a library or a piece of software if you notice it. Maybe you get a legacy code base dumped on your lap. This shit happens.

        • twoframesperminute@mastodon.social
          link
          fedilink
          arrow-up
          3
          ·
          11 months ago

          @jeremyparker Those are all valid. But not in a starter guide for someone looking to learn a language. If and when you get submerged into a legacy project you have all the time to find out what’s what. But teaching someone outdated syntax and features just because they *might* come accross them maybe is a terrible way to teach.

          • twoframesperminute@mastodon.social
            link
            fedilink
            arrow-up
            1
            ·
            11 months ago

            @jeremyparker Note that for people new to a language it’s much harder to distinguish between old and new than someone already familiar with the old. Don’t push old on people starting out.

            This is starting to feel like arguing kids should learn Latin because it might help them understand medical terms better. Sure, that’s true, but a) it’s only useful for a small subset of learners and b) is it worth the effort to learn an entire language just for some minor details?

            • twoframesperminute@mastodon.social
              link
              fedilink
              arrow-up
              1
              ·
              11 months ago

              @jeremyparker As for myself: I use Python as a scientist on an almost daily basis. I’ve never learned anything about Python 2, have never touched it and never required it. Maybe if you work in a field with tons of legacy code it’s useful, but I and all my colleagues are working with Python 3.7 or newer (mostly 3.10 and newer) only. There is no single argument you could make that would convince me I or any of my colleagues should know *anything* about Python 2.

    • ericjmorey@programming.devOP
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      11 months ago

      Thank you for your words of caution. I’ve copied below what the author has to say about Python 2 vs Python 3:

      Picking a Python Interpreter (3 vs 2) — The Hitchhiker’s Guide to Python

      .

      The State of Python (3 & 2)

      When choosing a Python interpreter, one looming question is always present: “Should I choose Python 2 or Python 3”? The answer is a bit more subtle than one might think.

      The basic gist of the state of things is as follows:

      1 - Most production applications today use Python 3.
      2 - Python 3 is ready for the production deployment of applications today.
      3 - Python 2 reached the end of its life on January 1, 2020 [6].
      4 - The brand name “Python” encapsulates both Python 3 and Python 2.

      Recommendations

      Note

      The use of Python 3 is highly recommended over Python 2. Consider upgrading your applications and infrastructure if you find yourself still using Python 2 in production today. If you are using Python 3, congratulations — you are indeed a person of excellent taste. —Kenneth Reitz

      I’ll be blunt:

      Use Python 3 for new Python applications. If you’re learning Python for the first time, familiarizing yourself with Python 2.7 will be very useful, but not more useful than learning Python 3. Learn both. They are both “Python”.

      So…. 3?

      If you’re choosing a Python interpreter to use, I recommend you use the newest Python 3.x, since every version brings new and improved standard library modules, security and bug fixes.

      Given such, only use Python 2 if you have a strong reason to, such as a pre-existing code-base, a Python 2 exclusive library, simplicity/familiarity, or, of course, you absolutely love and are inspired by Python 2. No harm in that.

      Further Reading

      It is possible to write code that works on Python 2.6, 2.7, and Python 3. This ranges from trivial to hard depending upon the kind of software you are writing; if you’re a beginner there are far more important things to worry about.

      • twoframesperminute@mastodon.social
        link
        fedilink
        arrow-up
        3
        arrow-down
        3
        ·
        11 months ago

        @ericjmorey Why are you copying part of an article you’ve already linked to? I’m not sure what your point is.

        My point is very simple: don’t spend any time on even considering Python 2. The fact the author spent so much time on it shows it’s quite an old guide. (The dates in the git repo confirms this.)

        • ericjmorey@programming.devOP
          link
          fedilink
          arrow-up
          2
          arrow-down
          1
          ·
          11 months ago

          The resource is about exactly this type of information. It’s not a resource that contains code examples. It has concisely presented information about things that aren’t in the Python documentation or is overly technical and verbose in the documentation. It’s a stepping stone providing context to getting more (and more current) resources.

          • twoframesperminute@mastodon.social
            link
            fedilink
            arrow-up
            1
            arrow-down
            3
            ·
            11 months ago

            @ericjmorey Except it’s outdated. Here, I’ll write a new paragraph for you: “When you start to learn Python, start with Python 3.10. If you at some point come across an codebase using older versions, you’ll have learned enough to get to grips with the differences outlined in Python documentation.” There, that’s all you need to know.