Live data from Hacker News

What's Coming in Python 3.8

lwn.net

271–280 of 558 posts

Re: What's Coming in Python 3.8

#271
post #24

Earlier quoted context omitted.

“I've come up with a set of rules that describe our reactions to technologies: 1. Anything that is in the world when you’re born is normal and ordinary and is just a natural part of the way the world works. 2. Anything that's invented between when you’re fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. 3. Anything invented after you're thirty-five is against the n…

It's wrong to frame this as resistance to change for no reason. See my other comment. I see some of this stuff as repeating mistakes that were made in the design of Perl. ...but there are quite few people around these days who know Perl well enough to recognize the way in which history is repeating itself, and that has at least something to do with age.

"resistance-to-change for-no-reason" vs "resistance-to change-for-no-reason" :)

Re: What's Coming in Python 3.8

#272

Earlier quoted context omitted.

Python 2.7 is not far from that language.

What's stopping people from forking the language at python 2.7? Let the pythonistas add whatever feature they feel like while people who need stability use "Fortran python" or whatever.

https://github.com/naftaliharris/tauthon

Re: What's Coming in Python 3.8

#273

Earlier quoted context omitted.

F-string are great and should have been in the language since the beginning. Many other languages had with their own version of them since version 0. What I don't understand is why Python needs a special string type when other languages can interpolate normal strings (Ruby, Elixir, JavaScript.)

f-strings need a prefix so old strings can keep working the same way. If `print("{x}")` printed "{x}" in Python 3.5, it shouldn't print something else in a newer version. But `print(f"{x}")` was a syntax error before f-strings, so no code is broken by giving it a meaning. JavaScript can't interpolate ordinary strings either, for the same reason. You need to use backticks (``).

You're correct about JavaScript. I forgot about the backticks.

Thank you for the explanation of the f-strings. I'm pretty sure that migrating old strings to "\{x\}" could be automated but we can't force everybody to migrate their code. There is probably no other way than the one they followed.

Re: What's Coming in Python 3.8

#274

I long for a language which has a basic featureset, and then "freezes", and no longer adds any more language features. You may continue working on the standard library, optimizing, etc. Just no new language features. In my opinion, someone should be able to learn all of a language in a few days, including every corner case and oddity, and then understand any code. If new language features get added over time, eventua…

Go? I moved a lot of my datascience and machine learning process to Go. Only thing really left in Python land is EDA

Re: What's Coming in Python 3.8

#275
post #8

Python looks more and more foreign with each release. I'm not sure what happened after 3.3 but it seems like the whole philosophy of "pythonic", emphasizing simplicity, readability and "only one straightforward way to do it" is rapidly disappearing.

In my experience, every technology focused on building a "simple" alternative to a long-established "complex" technology is doomed to discover exactly _why_ the other one became "complex." Also spawn at least five "simple" alternatives. Doesn't mean nothing good comes out of them, and if it's simplicity that motivates people then eh, I'll take it, but gosh darn the cycle is a bit grating by now.

Haha, what was that quote? Something like, any language is going to iterate towards a crappy version of lisp.

Re: What's Coming in Python 3.8

#276
post #202

Earlier quoted context omitted.

Can you give an example of something like this happening to the language? IMO 3.6+ brought many positive additions to the language, which I also think are needed as its audience grows and its use cases expand accordingly. The walrus operator makes while loops easier to read, write and reason about. Type annotations were a necessary and IMO delightful addition to the language as people started writing bigger productio…

What would "do/while" look like in Python? Since blocks don't have end markers (e.g. "end", "}", etc.) there's nowhere to put the while expression if you want the syntax to be consistent with the rest of the language.

One solution would be to borrow from Perl. You make a do block that executes once unless continued, and allow conditions on break and continue:

    do:
        thing()
        thing()
        continue if condition
And you can now express "skip ahead" with a `break if X` as well.

Re: What's Coming in Python 3.8

#277
post #177
post #25

Earlier quoted context omitted.

I love f-strings. I just wish tools like pylint would shut up when I pass f-strings to the logging module. I as the developer understand and accept the extra nanosecond of processor time to parse the string that might not be logged anywhere!

It's not always a nanosecond, some string representations can take a while to create. In poorly coded Django models they could involve a trip to the database.

    if logger.isEnabledFor(logging.DEBUG):
        logger.debug(f'{expensive_func()}')

Re: What's Coming in Python 3.8

#278
post #202

Earlier quoted context omitted.

What would "do/while" look like in Python? Since blocks don't have end markers (e.g. "end", "}", etc.) there's nowhere to put the while expression if you want the syntax to be consistent with the rest of the language.

I envisioned it like "if/else" or "for/else" or "while/else", where a "do" block must be followed by a "while" block. x = 0 do: x += 1 while: x

This completely contradicts the rest of Python grammar, and indeed many languages’ grammars. The consistent way would then be `while x < 10` but that too looks ridiculous. The issue is that you can’t have post-clause syntax in Python due to its infamous spacing-is-syntax idea.

Re: What's Coming in Python 3.8

#279

Earlier quoted context omitted.

F-strings have appeared 2 versions ago. All in all, the feedback we have has been overwhelmingly positive, including on maintenance and readability.

F-string are great and should have been in the language since the beginning. Many other languages had with their own version of them since version 0. What I don't understand is why Python needs a special string type when other languages can interpolate normal strings (Ruby, Elixir, JavaScript.)

Shells do it with "" and ''. Unfortunately Py and Js decided to allow both for regular strings, so there is not such an easy way to delineate them.

Re: What's Coming in Python 3.8

#280
post #133

Earlier quoted context omitted.

My metric for this is to put some of my freshest student in front of a code and see how they deal with it. How easily can they understand it ? How easily can they write it ? Debug it ? They are most of the time a fantastic indicator of the cognitive load a feature will add in prod. Because of course a feature doesn't exist in a vacuum, it's always in a more complex context. So what's easy to understand for a student…

> my freshest student in front of a code and see how they deal with it. That is fine if you want to optimize language for "fresh students". That is not representative how brain process stuff after getting even some experience.

It's not about experience vs inexperience... it's about code readability and being unsurprising.

    m = re.match(...)
    if m:
        ... do something ...
is verbose, but quite readable. Given that it's the way things have been done since forever, it's also unsurprising.

    if m := re.match(...):
        ... do something ...
Without knowing what the walrus operator is, it is not entirely clear what is going on here. := is only syntactic sugar, which is not what Python has ever been about.
Post reply on HN