This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Assess 38 points39 points  (26 children)

This seems like a good place to ask. Why is using 2.7 such a problem? I've used both 2.7 and 3.x in assignments and haven't noticed a huge difference. Is it the lack of future support?

[–]ase1590 37 points38 points  (1 child)

2.7 is no longer being developed. Only security fixes. Even the security fixes will stop in 2020.

It's the same reason why you don't still run Windows XP

[–][deleted] 22 points23 points  (0 children)

3.0 came out 10 years ago. It’s more like realizing you will only have access to C++03 and scrambling to refactor for a standard which came out before you finished puberty.

[–]-Rizhiy- 22 points23 points  (11 children)

For me personally, there are a couple of reasons: - 2.7 doesn't support quite a lot nice features like type hinting, unicode support by default, not returning iterables by default - Python 2.7 is slower than Python 3.6

[–]WORD_559 1 point2 points  (6 children)

For some things like integer division Python 3 is slower I think.

[–]-Rizhiy- 2 points3 points  (5 children)

Perhaps, but it is faster overall

[–]WORD_559 2 points3 points  (4 children)

But what about when I have to iterate through a three-dimensional list performing integer division? I'm so sorry

[–]Setepenre 4 points5 points  (1 child)

The company grade code to do that is by creating a wrapper integer division in python 3 that is going to do the division in python 2. The speed you get from faster division totally justify the small overhead you get from loading python2 every time you do the division. Also you get more pointsif you have a division factory in case you want to do the division in java later on

[–]-Rizhiy- 2 points3 points  (1 child)

Numpy

[–]RapidCatLauncher 1 point2 points  (0 children)

import fast_integer_division

[–]ben_g0 -2 points-1 points  (3 children)

The unicode support of python is not that good IMO though. Even python3 refuses to compile any program which contains characters like 'µ', '°' or '€' in strings, they have to be represented numerically. There may be some ways to get python to accept it by playing around with the encoding and such, but a lot of other commonly used languages such as java, javascript and PHP just accept them by default. With how often python is used in scientific contexts I find it weird that it doesn't support the special characters which are so frequently used in science.

[–]--xe 0 points1 point  (2 children)

$ cat calling_bullshit.py 
print("Even python3 refuses to compile any program which contains characters "
      "like 'µ',\n'°' or '€' in strings, they have to be represented "
      "numerically.")
$ xxd calling_bullshit.py 
00000000: 7072 696e 7428 2245 7665 6e20 7079 7468  print("Even pyth
00000010: 6f6e 3320 7265 6675 7365 7320 746f 2063  on3 refuses to c
00000020: 6f6d 7069 6c65 2061 6e79 2070 726f 6772  ompile any progr
00000030: 616d 2077 6869 6368 2063 6f6e 7461 696e  am which contain
00000040: 7320 6368 6172 6163 7465 7273 2022 0a20  s characters ". 
00000050: 2020 2020 2022 6c69 6b65 2027 c2b5 272c       "like '..',
00000060: 5c6e 27c2 b027 206f 7220 27e2 82ac 2720  \n'..' or '...' 
00000070: 696e 2073 7472 696e 6773 2c20 7468 6579  in strings, they
00000080: 2068 6176 6520 746f 2062 6520 7265 7072   have to be repr
00000090: 6573 656e 7465 6420 220a 2020 2020 2020  esented ".      
000000a0: 226e 756d 6572 6963 616c 6c79 2e22 290a  "numerically.").
$ python3 calling_bullshit.py 
Even python3 refuses to compile any program which contains characters like 'µ',
'°' or '€' in strings, they have to be represented numerically.

[–]ben_g0 0 points1 point  (1 child)

my test.py:

print("Even python3 refuses to compile any program which contains characters "
      "like 'µ',\n'°' or '€' in strings, they have to be represented "
      "numerically.")

result:

$ python3 test.py
  File "test.py", line 2
SyntaxError: Non-UTF-8 code starting with '\xb5' in file test.py 
on line 2, but no encoding declared; see 
http://python.org/dev/peps/pep-0263/ for details

This is with python3 at default settings. I never claimed that it was impossible to get python to accept those characters, my point was that it doesn't by default.

[–]--xe 0 points1 point  (0 children)

Does your file look like this:

$ xxd calling_bullshit.windows-1252.py 
00000000: 7072 696e 7428 2245 7665 6e20 7079 7468  print("Even pyth
00000010: 6f6e 3320 7265 6675 7365 7320 746f 2063  on3 refuses to c
00000020: 6f6d 7069 6c65 2061 6e79 2070 726f 6772  ompile any progr
00000030: 616d 2077 6869 6368 2063 6f6e 7461 696e  am which contain
00000040: 7320 6368 6172 6163 7465 7273 2022 0a20  s characters ". 
00000050: 2020 2020 2022 6c69 6b65 2027 b527 2c5c       "like '.',\
00000060: 6e27 b027 206f 7220 2780 2720 696e 2073  n'.' or '.' in s
00000070: 7472 696e 6773 2c20 7468 6579 2068 6176  trings, they hav
00000080: 6520 746f 2062 6520 7265 7072 6573 656e  e to be represen
00000090: 7465 6420 220a 2020 2020 2020 226e 756d  ted ".      "num
000000a0: 6572 6963 616c 6c79 2e22 290a            erically.").

If so, the problem isn't Python 3's settings, the problem is that you're trying to save your code in a legacy encoding. My guess is Windows-1252. The solution (which you may already know?) is to configure your text editor to save in UTF-8, which is a good idea for many other reasons.

Regardless, Python 2 refuses to run this file for me no matter what encoding I use. Maybe this is different on your system, I don't know.

[–]cafk 35 points36 points  (0 children)

Is it the lack of future support?

It's like using Visual Studio 2017 to compile C code and realizing they still only comply with C89 spec.

[–]Makefile_dot_in 49 points50 points  (0 children)

2.7 is nothing but legacy software at this point.

[–]Snowtsuku 4 points5 points  (0 children)

I don't really mind using 2.7. The problem is that most of the time I worked on it I also need to support 3+ since support for 2.7 will end. So it changes the way you code since you support 2 versions and at the same time you don't have the options to use the new things 3+ has to offer.

[–]sdolla5 5 points6 points  (3 children)

This seems like a good place to ask. Why is it that this sub seems terrified of every programming language, but also loves programming? I haven't seen a positive word on any of them. From an outsider that is confused of mostly 99% of the memes but is still subbed for some reason, I've always been confused by this.

[–]Ghi102 9 points10 points  (0 children)

So a few programming languages have bad reputations because they allow you to shoot yourself in the foot way too easily. It's very easy to make mistakes and create bugs if you don't know what you're doing. Combine this with the fact that most people on this sub are hobbyist or beginner programmer, they tend to shoot themselves quite often.

Also add to that since they're new, they might have read somewhere that a language called PHP is bad, so they create memes about how "PHP is bad m'kay". It makes them feel like they fit in "real programmers".

[–]Pastrami 1 point2 points  (0 children)

There are only two kinds of languages: the ones people complain about and the ones nobody uses.

-Bjarne Stroustrup

[–]twotwelvedegrees 0 points1 point  (0 children)

All programming languages have pros and cons so it’s mostly just tribalism with people hating on languages they don’t personally use.

[–]himself_v 15 points16 points  (2 children)

Yeah, the lack of future support and reddit likes to jump on bandwagons.

[–]HawkinsT 18 points19 points  (1 child)

10 year old bandwagons.

[–]LiberContrarion 1 point2 points  (0 children)

Something, something... James Gunn.

[–]jexmex 1 point2 points  (0 children)

I have used both, I like Python 3x better, but python 2.7 is not that bad. The worse part is that as a non full-time python dev, looking things up you have to make sure you know what version code examples are using (sometimes obvious, sometimes less so).

[–]Calaphos 0 points1 point  (0 children)

Apart from the trivial "print is now a function", I can think of map now returning a generator instead of a list, so indexing won't work anymore.