var: str = "Haha"
print(f"{var:_>20}")
print(f"{var:*^20}")
print(f"{str.lower() = }")
def concatenate[T: (str, bytes)](first: T, second: T) -> T:
return first + second
items = [1, 2, 3]
items [:]=[]
items = [1, 2, 3]
items *=0
bowl = ['water']
drink ,= bowl
n = 3
['a', 'b', 'c', *n* ['.']] #> ['a', 'b', 'c', '.', '.', '.']
a, *_ = (1,2,3)
My main issue with Python is the whole dependency management/venv situation. It's fine for single app/web-app deployment but when I have a hundred different Python projects on my computer and I need to easily run scripts from them several times a day. My solutions are... not elegant. My current scheme is to start moving my most frequently-used scripts into a monorepo under a single venv.
(recommendations happily accepted)
1. No "var" or "let" keyword, which requires you to read code, particularly with loops, more carefully
2. No multi-line lambdas, which forces you to move snippets away from their usage and come up with a name for them
3. Emphasis on classes and annotations over free functions, which is partly due to (2) but also the lack of a pipe operator, like in R
4. Modifying arithmetic operators (*=, +=, ++, --, etc...). These try to do too much at once. Use more intermediate variables and parens; it's much clearer.
5. "with" statement is a decent idea, but it should be usable without increasing nesting
The new type parameter syntax (PEP 695) newly added in 3.12 is certainly busy. I like the feature but I wish there was a better concise syntax. Metatype programming looks ugly in every language I've seen.
The rest of the statements have been around for ages, and I wouldn't call them recent or modern.
def concatenate[T: (str, bytes)](first: T, second: T) -> T:
return first + second
This isn't valid Python. items = [1, 2, 3]
items *=0
bowl = ['water']
drink ,= bowl
a, *_ = (1,2,3)
These are actually useful.None of these are new btw, I don't know about why you're asking the question like it's some new development.
One great thing about Python is that you can do a lot with it but the complexity is gradually exposed to you as you become a more advanced user which makes it both powerful and easy to get into.
As a teenager I’ve been "traumatized" by Pascal, but I was lucky to find a refuge in HTML and CSS. After I got a job as a web designer I discovered Python and I realized that I could actually program.
The people who came up with this new syntax have different needs that I do and probably have a different kind of brain than mine.
I looked up PEP 695 mentioned in another comment.
What do you think?
Its evolution has always been a sequence of compromises and tradeoffs.