Author Topic: Major Diff between python3 and python2  (Read 1148 times)

0 Members and 1 Guest are viewing this topic.

Offline $Clone

  • Peasant
  • *
  • Posts: 86
  • Cookies: 5
  • $---Shadowalker---$
    • View Profile
Major Diff between python3 and python2
« on: October 17, 2015, 02:31:10 pm »
I know google can help... ::) ::)..but i wanted to get a real insight of guys who were once python2 lovers but have now cheated with python3....What are the major programming difference other than print having brackets().And also why python3 and not python2....lets make this a final discussion on the topic  :D

Offline TheWormKill

  • EZ's Scripting Whore
  • Global Moderator
  • Knight
  • *
  • Posts: 257
  • Cookies: 66
  • The Grim Reaper of Worms
    • View Profile
Re: Major Diff between python3 and python2
« Reply #1 on: October 17, 2015, 02:45:54 pm »
Well, I started with python2 (not sure when). However, I recently started doing more stuff in python3, and I can't say that I have a definitive answer which of the flavours should be used. The wiki article here is of great help if you face the decision.
The major difference lies in changes in modules, import syntax, new features (such as type hints), and some political reasons (such as modules being (not) ported over (yet) or ongoing development on py3 vs. no new versions beyond python 2.7.x). So make your choice based on that, but be prepared to work with both.
Or use something else entirely if you want to push your programming abilities further (biased Haskell fanboy speaking).

Beyond the above, there isn't much to say other than opinions, but some discussion is in fact appropriate.
Stuff I did: How to think like a superuser, Iridium

He should make that "Haskell"
Quote
<m0rph-is-gay> fuck you thewormkill you python coding mother fucker

Offline $Clone

  • Peasant
  • *
  • Posts: 86
  • Cookies: 5
  • $---Shadowalker---$
    • View Profile
Re: Major Diff between python3 and python2
« Reply #2 on: October 17, 2015, 11:59:43 pm »
I see....so basically they are hoping people will transition from python2 to python3.But if you think about it its kinda silly to have two versions of the same thing....Instead they could have just made the changes to python2 and move on....anyway i love python so i guess learning both ain't bad
« Last Edit: October 18, 2015, 12:00:38 am by $Clone »

Offline ptales

  • Peasant
  • *
  • Posts: 75
  • Cookies: 10
  • Perfected Imperfection
    • View Profile
Re: Major Diff between python3 and python2
« Reply #3 on: October 18, 2015, 01:25:06 am »
I'll agree with TheWormKill. The major advantage of Python 2 is that it's widely used / supported whilst Python 3 is still pretty rare. Python 3 has it's advantages, though. If you really want to learn something else, don't just switch to Python 3 but learn a different programming / scripting language instead. Python 2 can be converted into Python 3 easily (most of the time, but not always) - there even are tools that do that kind of work for you automatically, after all.
You're right about it being silly to have to versions of the very same thing, but not everything can be automatically converted from Python 2 to Python 3 and that's why Python 2 is still more common than Python 3 - once a standard has been set, it's likely to stay for quite a while.
I'd say learn Python 2 first - as that's what you'll find in the "real world" more often nowadays - and then learn Python 3 afterwards, as that's likely to be the "future" of Python.

//Just to make this clear:
Once you've learned Python 2, learning Python 3 will be easy (and most likely the other way around, too).
« Last Edit: October 18, 2015, 01:26:41 am by ptales »
'Until they become conscious they will never rebel, and until after they have rebelled they cannot become conscious.'

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: Major Diff between python3 and python2
« Reply #4 on: October 18, 2015, 01:51:47 am »
I think one of the biggest diffs now is that strings are unicode and not ascii anymore. Also modules are cached when imported, which can kinda mess you up when your searching directories.

Here is python 2to3 and 3to2 which helps automate converting between the two.

https://docs.python.org/3.0/library/2to3.html

https://pypi.python.org/pypi/3to2/1.1.1
>>>import this
-----------------------------

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Major Diff between python3 and python2
« Reply #5 on: October 18, 2015, 01:58:19 am »
I never really differentiate between the two when i am coding. I have both of them in my mind and code code portable to both platforms, so meh.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline fayesafe

  • /dev/null
  • *
  • Posts: 14
  • Cookies: 4
    • View Profile
Re: Major Diff between python3 and python2
« Reply #6 on: October 18, 2015, 10:48:46 am »
I think one of the biggest diffs now is that strings are unicode and not ascii anymore. Also modules are cached when imported, which can kinda mess you up when your searching directories.

Here is python 2to3 and 3to2 which helps automate converting between the two.

https://docs.python.org/3.0/library/2to3.html

https://pypi.python.org/pypi/3to2/1.1.1

Talking about Strings now being unicode, is there any way to avoid/prevent this? I was recently working with files that were encoded with base64 and the base64-functionality in python needs binary String as input. So I needed to first encode the unicode-String to ascii and then decode it with base64. I did not find anything about this topic on the interwebs, so maybe someone has a hint.
I reserve the right to be wrong. I reserve the right to change my mind.

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Major Diff between python3 and python2
« Reply #7 on: October 18, 2015, 09:46:13 pm »
Talking about Strings now being unicode, is there any way to avoid/prevent this? I was recently working with files that were encoded with base64 and the base64-functionality in python needs binary String as input. So I needed to first encode the unicode-String to ascii and then decode it with base64. I did not find anything about this topic on the interwebs, so maybe someone has a hint.
You are thread raping my friend. Start a new topic on this.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline Jackal

  • Serf
  • *
  • Posts: 32
  • Cookies: -17
    • View Profile
Re: Major Diff between python3 and python2
« Reply #8 on: January 11, 2016, 06:24:05 am »
Well I prefer ruby and perl but when I use python I have to use 2 because 3rd party modules don't work well yet on 3 but I heard python3 has much better OO suport which honestly I don't really care much for I'm used to writing almost purely functional scripts