Live data from Hacker News

What’s New in Python 3.8

docs.python.org

71–80 of 381 posts

Re: What’s New in Python 3.8

#71
post #22

As a developer who has primarily developed applications in Python for his entire professional career, I can't say I'm especially excited about any of the "headlining" features of 3.8. The "walrus operator" will occasionally be useful, but I doubt I will find many effective uses for it. Same with the forced positional/keyword arguments and the "self-documenting" f-string expressions. Even when they have a use, it's us…

Perl devs have been using the walrus expression for decades, but we just called it "assigning a variable with local scope in an expression". $ perl $a = "foo"; if ( my $a = "bar" ) { print "$a\n" } print "$a\n" bar foo

Yup, C and many other languages also have it:

    if (ptr = strchr(address, ':'))
        port = atoi(ptr + 1);

Re: What’s New in Python 3.8

#72
post #22

As a developer who has primarily developed applications in Python for his entire professional career, I can't say I'm especially excited about any of the "headlining" features of 3.8. The "walrus operator" will occasionally be useful, but I doubt I will find many effective uses for it. Same with the forced positional/keyword arguments and the "self-documenting" f-string expressions. Even when they have a use, it's us…

Perl devs have been using the walrus expression for decades, but we just called it "assigning a variable with local scope in an expression". $ perl $a = "foo"; if ( my $a = "bar" ) { print "$a\n" } print "$a\n" bar foo

The reason why assignment expressions initially were not allowed in Python and why they had to introduce "walrus" was because in languages that used single equal sign for assignment enable to easily make bugs by typing "=" instead of "==".

Re: What’s New in Python 3.8

#73
post #22

As a developer who has primarily developed applications in Python for his entire professional career, I can't say I'm especially excited about any of the "headlining" features of 3.8. The "walrus operator" will occasionally be useful, but I doubt I will find many effective uses for it. Same with the forced positional/keyword arguments and the "self-documenting" f-string expressions. Even when they have a use, it's us…

> As a developer who has primarily developed applications in Python for his entire professional career, I can't say I'm especially excited about any of the "headlining" features of 3.8.

Python is a fairly old, mature language.

What features would you have been especially excited about?

Re: What’s New in Python 3.8

#74

Earlier quoted context omitted.

>They didn't select my preferred syntax I don't write much python so there's probably something obvious I'm missing, but I don't see why they didn't use "=". Is there some significant difference between assignment expressions and assignment statements that makes it worth having distinct syntax?

Yes, there is. If x = 1 Has been the source of many errors in many languages. Forcing assignment to be more than a 1 character difference from the equality operator prevents this.

I may be missing something, but := is still only a 1 character difference, isn't it?

Re: What’s New in Python 3.8

#75
post #65

Earlier quoted context omitted.

> which itself is a result of limiting ourselves to the ASCII symbols that can be typed I think we're ready for programming languages using some visually good Unicode characters, instead of overloading `[]{}!@#$%^&*()-_/` for everything!

Oh god, this. I want a language that as I type, != Gets replaced with a proper ≠ not equals sign and proper symbols for AND, OR, and NOT.

a lot of programming fonts have ligatures for this

Re: What’s New in Python 3.8

#76
Buried in the notes for the `typing` module:

> “Final” variables, functions, methods and classes. See PEP 591, typing.Final and typing.final(). The final qualifier instructs a static type checker to restrict subclassing, overriding, or reassignment:

> pi: Final[float] = 3.1415926536

As I understand it, this means Python now has a way of marking variables as constant (though it doesn't propagate into the underlying values as in the case of C++'s `const`).

The equivalent Java:

    final float pi = 3.1415926536;

Re: What’s New in Python 3.8

#77

Earlier quoted context omitted.

I take this as a positive sign of Python's maturity.

. . .and the threat of Just Another Vict'ry Announcement (JAVA) as the need to add "sizzle" to the next version looms.

Rock and a hard place, no? Either you keep adding to a language and people keep using it, or you stop adding to a language and people call it a dead language and stop using it.

Most devs don't understand that software can be done and still be useful.

Re: What’s New in Python 3.8

#78
post #74

Earlier quoted context omitted.

Yes, there is. If x = 1 Has been the source of many errors in many languages. Forcing assignment to be more than a 1 character difference from the equality operator prevents this.

I may be missing something, but := is still only a 1 character difference, isn't it?

:= is basically the "yes, I really mean it" version, whereas bare = might just be a simple typo.

Re: What’s New in Python 3.8

#79
post #74

Earlier quoted context omitted.

Yes, there is. If x = 1 Has been the source of many errors in many languages. Forcing assignment to be more than a 1 character difference from the equality operator prevents this.

I may be missing something, but := is still only a 1 character difference, isn't it?

It is, but many intro programmers (and non-intro programmers!) often forget to use == instead of = for comparison, because in the real world, = more often implies equality, rather than assignment. So a novice might mistakenly type `if x=1:` but they would be unlikely to accidentally type `if x:=1:`.

Re: What’s New in Python 3.8

#80
post #14

> The typing module incorporates several new features: > A dictionary type with per-key types. Ah, I've been waiting for this. I've been able to use Python's optional types pretty much everywhere except for dictionaries that are used as pseudo-objects, which is a fairly common pattern in Python. This should patch that hole nicely.

IMO A better fix is to use http://attrs.org or dataclasses to replace the dicts entirely.

Agreed--if you're going to go through the trouble of adding detailed type hints to describe a dict, you're like 90% of the way to a dataclass with better usability.
Post reply on HN