1. 24

  2. 7

    FWIW, this is for RC1, python3.6 final isn’t out yet.

    1. 3

      But it seems unlikely that they’ll change that list at all in the next 8 days (when the full release is scheduled)

      1. 4

        Sure, just in case people read this and get confused when they try to install it.

    2. 3

      Look forward to playing with the asynchronous generators and list comprehensions.

      Also the nice simple string formatting :)

      1. 9

        How many different ways can you format strings now?

        value = 'test'
        # 1
        "%s" % value
        # 2

        Has pep-20 been forgotten? What happened to “There should be one – and preferably only one – obvious way to do it”?

        1. 9

          (1) should be considered deprecated. I would have loved to see it go away in 3.x, but I assume it remains to support legacy code.

          (2) and (3) are the same mechanism. It’s analogous to *args vs. **kwargs.

          (3) is now just the implementation behind (4). I wouldn’t considering them separate.

          1. 6

            A few things:

            • You forgot the Template system.

            • Numbers 2 and 3 on your list are just variations on format() and are basically the same.

            • The new f"{value}“ syntax appears to be just a shorthand for ”…“.format().

            Anyway, I’ve seen this complaint specifically about Python3 at least twice now, and don’t really understand it. Python2 already had a lot of ways to format strings, so why complain now? A new variation on an existing method isn’t hurting anything.

            As far as PEP-20 goes, having one way to do something is only one item on the list, and I’d say this new system helps with several others, so it’s a trade off. There are a many ways to loop, too, and nobody complains about that. In an ideal world or brand new language I’m sure they’d love to get rid of at least % formatting and maybe even .format(), but after all the whining about things breaking in Python3 they’re probably not in a huge hurry to break something that will impact literally almost everybody using the language.

            1. 4

              You forgot the Template system.

              I purposefully left it out, but you are probably right that it is similar enough to be included in my list.

              Python2 already had a lot of ways to format strings, so why complain now?

              Why not? I complained then too! python3 was supposed to be the time to break things and clean things up. It just seems like an odd wart to have so many ways to do string formatting.

              Comparing this to looping constructs seems a bit disingenuous.

              1. 1

                Fair enough. I had personally never heard this complaint before except just recently in relation to Python3.

            2. 3

              Sure it’s redundant, but it doesn’t seem like an interestingly harmful kind of redundancy to me, because none of the string formatting mechanisms interact with each other in any interesting way. After the expression is evaluated, you can’t distinguish what kind of format string was used by looking at the value. The vast majority of the time the format string will be a literal constant too, so other code won’t be able to distinguish what type of format string was used prior to the expression being run either.

              It’s not awkward like, say, mixing several different object systems (like we had with ‘old style classes’ vs ‘new style classes’ in Python 2.2 through 2.7) where you have to remember which one has been used, maybe you can mix both in one class’s inheritance diagram, and the differences between the two are actually a little subtle to begin with.

              1. 5

                I’m with you here. I’ve always found the need to use .format() or % for string interpolation to be needless boilerplate, having come from languages like Ruby or even dare I say it Perl where string interpolation happens out of box.

                If anything, I find the ‘f’ syntax to be rather elegant because, unlike these other languages, you don’t get bitten by interpolation when you’re not expecting it. In that sense, I find the new syntax to be very Pythonic.

          2. 2

            String formatting is awesome: https://docs.python.org/3.6/whatsnew/3.6.html#whatsnew36-pep498

            Type hints could be useful for certain libraries. Will make it a bit harder for beginners to read codebases using it though.