I personally prefer the 3 syntax over 2,
but I notice most of the code snippets in this forum are for Python 2.

Is it because we are still in a steady transition from 2 to 3, or is it something else?

Dani AI

Generated

Back in 2010 the forum skewed toward Python 2 for the practical reason several members noted: an ecosystem still in transition. ’s observation is the same reality and described — many packages and deployment tools hadn’t yet moved, so examples you see from that era target 2.x.

Fast-forward: Python 2 is officially end-of-life (no upstream fixes or security updates as of January 1, 2020). (python.org) Packaging tooling followed: pip removed Python 2 support in the 21.0 release (January 2021), so modern installers and wheels are focused on Python 3. (pip.pypa.io) The practical takeaway: start new projects on Python 3 and plan to migrate legacy 2.x code off that platform.

A short, practical upgrade path:

  1. Create isolated environments and test your code under Python 3 (use venv or tools like pyenv to run multiple interpreters).
  2. Use automated converters cautiously — the old 2to3/lib2to3 tool is deprecated and scheduled for removal; consider parser-based tools (LibCST/parso) and manual review for tricky code. (docs.python.org)
  3. For gradual compatibility, six or the future project can help while you port. (pypi.org)
  4. Run your full test suite and CI across the target Python 3 versions before switching production.

Quick setup example (local dev):

python3 -m venv .venv
source .venv/bin/activate   # Windows: .\.venv\Scripts\activate
pip install -U pip setuptools wheel

A few troubleshooting notes tied to earlier posts: as and discussed, the main conceptual change is where text and raw bytes live — treat text as Python 3 str and perform encode/decode only at I/O boundaries, and watch for iterator/dict API differences when converting code. If a dependency blocks you, isolate it (container/VM) and upgrade the rest of your stack first.

Recommended Answers

All 16 Replies

I for one, am waiting for more 3rd party modules to switch over to 3.X. Then I will start using 3.X more

Same reason. Most existing modules are for python 2. I prefer python 3, but I 'm using python 2.

The Python world is going through a transition. I do more and more work with Python 3.1.2, but still use Python 2.6.5 for some stuff.

Most folks are waiting for wxPython and PIL to make the transition. In the mean time I am using the PyQT GUI toolkit and the newer version of Tkinter that ships with Python31

I'm still using 2.6, but I have the newest 3 installed. I don't use 3, because there aren't many modules made for it. However, I do try and use 3's syntax in 2.6 where applicable (ie print("") not print ""). I do wish that I could do one liner "for" statements with Python, but I guess that'll have to wait xP

I'm still using 2.6, but I have the newest 3 installed. I don't use 3, because there aren't many modules made for it. However, I do try and use 3's syntax in 2.6 where applicable (ie print("") not print ""). I do wish that I could do one liner "for" statements with Python, but I guess that'll have to wait xP

You can also use from __future__ import print_function .

I use python 2.6 :-)

This version i look on study, so i use this version ;) I hear, many modules dosen't work in python 3.x

My english suck ;d

waiting on a new release of py2exe

If I have any dependencies that require 2x, I use 2x. Otherwise I use 3.

Get used to Python3. Where the difference between Python2 and Python3 hits you hard, is in unicode applications and the fact that many functions expect and return byte strings rather than strings.

@ Vegaseat:
What is the difference between a byte string and a string?

@ Vegaseat:
What is the difference between a byte string and a string?

----------------------------------
python 2        |   python 3
----------------------------------
string          |   byte string
unicode string  |   string
----------------------------------

I don't understand? So something like this in python 2: print("Hello") is a string in 2, and a byte string in 3;
while print(u"Hello") is a unicode string in 2, and a string in 3?

I don't understand? So something like this in python 2: print("Hello") is a string in 2, and a byte string in 3;
while print(u"Hello") is a unicode string in 2, and a string in 3?

no, "hello" has type 'str' in python 3 but it is a unicode string. On the other hand, b"hello" has type 'bytes' and it's a sequence of bytes (what we called a string in python 2).
The idea is that everything is unicode by default in py 3. There is no 'unicode' type.

I'm so confused. So only the technical names change, correct? I never really learned about "types" or anything. I've been programming an making full-blown applications without learning that kind of stuff. So do I have to learn it now?

I'm so confused. So only the technical names change, correct? I never really learned about "types" or anything. I've been programming an making full-blown applications without learning that kind of stuff. So do I have to learn it now?

It's a good idea to learn about types, but in this case, the important point is to understand the difference between an array of bytes and a unicode string. A unicode string is an abstraction with theoretical characters, an array of bytes is raw memory with short integer values.

Ah okay. I think i understand. What I meant was that I didn't really study types. I get the gist, like str, unsigned int, etc. Just what you said was a bit confusing xP Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.