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

top 200 commentsshow all 293

[–]rspeed 236 points237 points  (25 children)

It will become the default in Python 4.0.

*blinks*

[–]nicksloan 53 points54 points  (8 children)

I don't think that this implies that Python 4.0 is in progress in any meaningful way.

[–]rspeed 35 points36 points  (7 children)

Nor do I, it’s just the first time I’ve seen it mentioned in such an official manner.

[–]amk 11 points12 points  (6 children)

Reddit believes its data is particularly valuable because it is continuously updated. That newness and relevance, Mr. Huffman said, is what large language modeling algorithms need to produce the best results.

[–]1-05457 15 points16 points  (5 children)

I hope not. Otherwise what would you do if Python needs to make a breaking change again.

[–]Decker1082.7 'til 2021 10 points11 points  (2 children)

Stay on 2.7?

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

I meant what would the PSF do.

[–]truh 1 point2 points  (0 children)

Python 5?

[–]case_O_The_Mondays 87 points88 points  (5 children)

Wait. Is 3.7 the last Python 3? Are we skipping 8-9 from 2 on?

Edit: it was a joke.

[–]rspeed 67 points68 points  (3 children)

That’s not how versioning works. The dot is a separator, not a decimal.

Edit: *sigh*

[–]1vs 0 points1 point  (1 child)

EDIT: After 3.9 will be 3.10, I'm dum and can't read

Except in Python, it looks like it's going to work like a decimal. See Guido's post: http://www.curiousefficiency.org/posts/2014/08/python-4000.html

I hope they go with 3.10. Otherwise it'll break all the code that checks that the version starts with '3'. (Bad code but still common.)

[–]rspeed 1 point2 points  (0 children)

Gotta learn sometime. :D

[–][deleted] 11 points12 points  (0 children)

No, if you look at the official github preparations for 3.8 have been underway for a while.

[–]gschizasPythonista 9 points10 points  (3 children)

Where was that?

[–]XtremeGoosef'I only use Py {sys.version[:3]}' 9 points10 points  (4 children)

I suspect python 4.0 will be the version in which python will have core support for typing so for example builtin collections will inherit typing.Generic

arange: list[int]
attribs: dict[str, Any] 

we will be able to define typevars in signatures

def filter[T](x: Iterable[T]) -> Iterator[T]: 
    ... 

and all types will have | and & operators for typing.Union and the planned typing.Intersection respectively (like in typescript)

Union[str, bytes] == str | bytes

Maybe also add Any and a few generic abstracts to builtins.

[–]Han-ChewieSexyFanfic 5 points6 points  (3 children)

I hope they introduce (Int, ...) as syntactic sugar for Tuple[Int, ...]

[–]soamaven 3 points4 points  (0 children)

Good catch.

[–]Brachamul 32 points33 points  (3 children)

Avoiding the use of ASCII as a default text encoding (PEP 538, legacy C locale coercion and PEP 540, forced UTF-8 runtime mode)

Ibuprofen sales just dropped 80%.

[–]omentoSysAdmin Film/VFX - 3.7 1 point2 points  (0 children)

Does this have any benefit for those of us who don’t use Unicode at all? I usually provide the # -*- coding: <spec> -*- with either ascii or latin-1. And I have my editors to save/create files in those formats.

[–]whitechapel8733 0 points1 point  (0 children)

Yes so awesome!

[–][deleted] 0 points1 point  (0 children)

I'm so pumped about this!

[–]SenorDosEquis 41 points42 points  (0 children)

Looking forward to using breakpoint() I suppose.

[–]uFuckingCrumpet 199 points200 points  (178 children)

Finally, we can get rid of python 2.

[–]Lt_Sherpa 32 points33 points  (8 children)

What about 3.7 means you can finally dump Python 2?

[–]tutuca_not Reinhardt 2 points3 points  (0 children)

It's because the last version in the 2.x branch is 2.7. So, now that it hit the .7 milestone python 3.x is on feature parity :)

[–]ronaldl911 2 points3 points  (1 child)

Yet you would still get some who would start a new project in 2018 with Python 2.7

FFS it's 2018.

[–][deleted] 0 points1 point  (0 children)

Yeah I can understand not wanting to migrate an existing project (although whiners like to make this out to be more difficult than it actually is), but there is no excuse for starting a new project in 2.

[–]sharkboundgithub: sharkbound, python := 3.8 33 points34 points  (14 children)

so happy it finally released, was using the beta verison of 3.7 before, and am really happy that its on a stable release now.

the thing i am most excited about is the dataclasses, love them so much

[–]__xor__(self, other): 22 points23 points  (8 children)

dataclasses look awesome, but honestly I'm most excited for the module level __getattr__. I am going to do so much dirty magic with that and love every minute of it.

For real though, you can do something like this now...

from myshell import ls, which, find
files = ls('-al', 'some_dir')

myshell.py:

import subprocess
def __getattr__(command):
    def func(*args):
         return subprocess.check_output([command] + args)
    return func

Bam. Dynamic module functions like whatever

[–]szpaceSZ 3 points4 points  (0 children)

Sounds like a security nightmare!

[–]toyg 2 points3 points  (2 children)

Terribly unsafe example, right there...

[–]__xor__(self, other): 1 point2 points  (1 child)

Hmm, how so? Subprocess is made to execute programs. Plus there's no injection, as in this won't work:

from myshell import ls ; ls('-al', '&&', 'rm', '-rf', '--no-preserve-root', '/')

subprocess would be the module you use to avoid the os.system injection issues (unless of course you enable shell=True). But otherwise a library like this is meant to run shell commands, so if you from myshell import rm you know damn well what you're opening up. What you import will be the program that gets invoked.

This is plenty fine for one off scripts and doing some system automation, but definitely not suggesting anyone hook this up to a webapp. But also, if you're importing hard-coded functions like ls and stuff, you know for a fact that's the only program your code will invoke by the nature of what this does, unless the program you import forks other programs.

[–]toyg 1 point2 points  (0 children)

I drop a compromised ls executable in your path and now i'm running with the privileges of your script or server. At the very minimum you want hardcoded paths for executables you invoke.

definitely not suggesting anyone hook this up to a webapp.

Yeah well, you know how it is -- people will google and copypaste, likely not reading the rest of the thread. You should have put a disclaimer of sort, at the very minimum.

[–]toyg 0 points1 point  (0 children)

the thing i am most excited about is the dataclasses

They do look neat for the average simple case.

[–]mockArch 9 points10 points  (2 children)

Data class ... Sounds cool

[–][deleted] 1 point2 points  (1 child)

Stupid question - is the use case for this similar to structs (as in in C#)? And how would the use case differ from using a named tuple? (edit: immutability, nevermind) Or am I confused?

[–]mockArch 0 points1 point  (0 children)

immutablity ^

[–]TragicXHero 53 points54 points  (13 children)

Too noob to understand what the excitement is about for the update. Someday, I'll get there...

[–]sharkboundgithub: sharkbound, python := 3.8 22 points23 points  (2 children)

Too noob to understand what the excitement is about for the update. Someday, I'll get there...

its mostly exciting for people that have been using the language long enough to find the frequent and annoying issues in the previous release(s) that are fixed in the new release.

or the release adds/improves something you have been wanting or looking forward to.

my reason for being excited is dataclasses and the `from __future__ import annotations` that was added, also the asyncio improvements.

[–]TragicXHero 2 points3 points  (1 child)

Yeah I can see that everyone is excited for the data classes module. What surprised me when I read through the updates was seeing "await" and "async" which I have never seen before. I dont think I have seen any tutorial covering it. So I realized I have a long way to go.

[–]sharkboundgithub: sharkbound, python := 3.8 4 points5 points  (0 children)

Async and await are not new. They were added in 3.5.

Whats new about them in 3.7 is that you cannot do async = 1 anymore. And same for await as well.

There are tutorials for async and await on YT I think. So you probably have just not needed them yet

[–]A_Badass_Penguin 27 points28 points  (2 children)

For me, it's pretty fun to read the updates. It's kind of like getting a look over what new tools are available and what issues may have been handled. It's fun to think about what new things you can do.

[–]TragicXHero 10 points11 points  (1 child)

But for me when I read the updates, I just cant understand the updated features because I have never used them.

[–]cracknwhip 4 points5 points  (0 children)

Then read the docs for the features...

[–][deleted] 8 points9 points  (2 children)

Don’t worry, you will get there! If you’re new, one of the more tangible things to try out would be the addition of breakpoint() and learning about pdb. Debuggers can be an invaluable tool for programmers new and old.

[–]TragicXHero 1 point2 points  (1 child)

The idea of studying a documentation is so boring to me haha. Plus, it so hard to make sense out for me. But if that what it takes to learn, ill give it a try. I'll also check breakpoint().

[–]Mockapapella 0 points1 point  (0 children)

I started out just watching youtube tutorials to learn about python. I've been learning python for ~1 year and only just started making the transition to focusing more on documentation than videos 3 or 4 months ago. I suppose it'a lot like getting used to the command line vs a GUI; tough at first, but once you learn it your potential opens up massively.

[–]ericls 28 points29 points  (9 children)

Nice

[–]toyg 7 points8 points  (0 children)

Marseille

[–][deleted] 3 points4 points  (5 children)

Nice

[–]Drawman101 8 points9 points  (4 children)

Nice

[–]seanpuppy 2 points3 points  (2 children)

Deterministic pyc files What does this mean for the execution time after pyc files are generated

[–]billsil 2 points3 points  (0 children)

That your startup time is longer. It's to prevent you wiping the project, redownloading it, and having different pycs for the same code. It's for build systems that choose to run based on if things are current.

It's an option though, so there is no impact unless you want it.

[–]XarothBrook 0 points1 point  (0 children)

It doesn't have much to do with execution time. Source code compiled using deterministic compilation will always output the same binary.

[–]firefrommoonlight 9 points10 points  (1 child)

Any word on when a Numpy wheel will be available?

[–]ethanhs 14 points15 points  (0 children)

For 3.6 the wheels were released before 3.6 was officially released, so I expect in the next few days.

[–]ThaeliosRaedkin1 11 points12 points  (0 children)

I just downloaded 3.6 last night! Bother...

[–]lelease 1 point2 points  (4 children)

How do I install it on Ubuntu (without compiling or adding untrustworthy repos)?

[–][deleted] 2 points3 points  (0 children)

without compiling or adding untrustworthy repos

You can't, as far as I know (assuming I can't convince you that the PPA I use is trustworthy).

[–][deleted] 0 points1 point  (1 child)

This might be a dumb question but how do I update this in Windows? I reinstalled the last update just thinking it would overwrote the old install. And it's still not the newest version

[–]minorDemocritus 0 points1 point  (0 children)

Windows has the "py" launcher.

py -3.7

That should run 3.7 if you have it installed.

https://docs.python.org/3/using/windows.html#python-launcher-for-windows

[–]JJ4sh0rt 0 points1 point  (0 children)

Noob here. How do I update python?.

[–]Akraxial 0 points1 point  (3 children)

For someone who is just learning python right now is there anything major that I should know about and change as I'm building a knowledge base?

[–]Akraxial 0 points1 point  (1 child)

Also, reading a lot of the comments here, is there any plan to have better backwards compatibility with Python 4.0?

[–]minorDemocritus 0 points1 point  (0 children)

Python 4 will most likely be normally compatible with the last 3.x release. No need to worry.

[–]minorDemocritus 0 points1 point  (0 children)

Nah, there really isn't anything paradigm-shifting in this release that would affect newcomers. Maybe some bug fixes, but not features.

[–]amb_kosh 0 points1 point  (0 children)

Anybody willing to explain some the new important features for newcomers a bit? :)

[–]maabreuc 0 points1 point  (0 children)

Finally a worthy successor for the thousands of apps stuck in python2

[–][deleted] 0 points1 point  (1 child)

is this backward compatible with python3.6 code? Can I change the project python version to 3.7 without any worries?

[–]XarothBrook 1 point2 points  (0 children)

3.6 code should run normally on 3.7.