4 ms·
The walrus operator, the `match` statement, the f-strings etc. these seem like just syntactic sugar. Also note the type hints are optional. So these changes are
by alexaholic 5y ago
The walrus operator, the `match` statement, the f-strings etc. these seem like just syntactic sugar. Also note the type hints are optional. So these changes are opt in: you can still write the Python of yesterday. But, if you can afford to take it up a notch, you can write the Python of today. I don't see Python getting harder for the newcomers, instead I find it getting better for the ones who have invested deeply into it, and I quite enjoy it.
- chriswarbo 5y ago> these changes are opt in Only for personal projects, with no outside contributors, no external dependencies, etc. If you want to read someone else's code, e.g. to learn more, or see how one of your dependencies works, etc. then you may need to face these features. If you want to allow external contributions to your project, then you'll have to face these features (even if that just means an informal coding standard that says "don't use XYZ"). If you want to work more closely/collaboratively with others, e.g. in an organisation, then you'll have to face these features (even if it's just a discussion about whether to allow them). If you want to write tooling for the language, e.g. parsers, doc generators, linters, formatters, diffing tool, etc. then you'll need to face them. Finally, if you're writing library code that's intended for use by others, you need to be aware of such language features, in case they break any of your assumptions. For example, a library might rely on the fact that lambdas can't re-bind variables (they can mutate the content of an object, but they can't change the reference, since '=' is a statement rather than an expression); the introduction of ':=' expressions violates that assumption.
- popularonion 5y agoIn the real world, I'm still nagging people to use docstrings and type hints. It is really not my experience that people read PEPs and try to shoehorn in language tricks they don't need into their random scripts at $DAYJOB. I would actually be thrilled to see a walrus operator show up in a PR from one of my coworkers. But I'd have to shoot it down because we need to be compatible with 3.6.
- anhner 5y agoWhat if a newcomer wants to make sense of a large codebase that uses all the new features? It used to be that Python was mostly similar to pseudocode, easy to understand and reason about. Now all this "syntactic sugar" just makes it harder to read IMO.
- deleted 5y ago[deleted]