Apr-22-2021, 12:22 AM
Pages: 1 2
Apr-22-2021, 02:50 AM
(Apr-22-2021, 12:22 AM)Skaperen Wrote: [ -> ]how would you feel if Python's assignment operator was := instead of just = ?Would have been incredibly silly change now as it has been
=
since the start.As
:=
was free added in Python 3.8(🐳rus operator) >>> print(num = 99) Traceback (most recent call last): File "<interactive input>", line 1, in <module> TypeError: 'num' is an invalid keyword argument for print() # Walrus power >>> print(num := 99) 99Saves us from calling
len()
twice.lst = [1, 2, 3, 4] if (n := len(lst)) > 3: print(f"List is too long <{n} elements,need to be <= 3>")
Output:List is too long <4 elements,need to be <= 3>
Apr-23-2021, 06:03 PM
i'm not asking in terms of a change, but rather, what if it had been that way since the beginning (e.g. would be silly to change it to =, now).
Apr-24-2021, 09:13 AM
(Apr-22-2021, 12:22 AM)Skaperen Wrote: [ -> ]how would you feel if Python's assignment operator was := instead of just = ?
I won't feel any change, because of some relativistic effects during time travel.
I use from the IEC 61131-3 standard the Structured Text. The syntax is similar to Pascal, and it's not vendor-specific.
https://en.wikipedia.org/wiki/Structured_text
The
:=
is used for assignment. A plain colon is followed by a datatype and comparison is made with =
.I don't have bad feelings to write
:=
and if Python had this instead of =
, I think we won't recognize it or talk much about it.Changing this decision afterwards without breaking all existing code is nearly impossible.
Apr-25-2021, 06:03 PM
of course any change like that after it is established is, at best, a new language; entirely unsuitable for the previous.
but being one that dislikes typing := when i would need to type it a lot, i can say that the me in that universe where Python was created with := would likely not be coding in Python. i'm not sure what i would be using. maybe still doing Pike. but it seems to have stalled out, at least in this universe. in both cases there is still a little C.
but being one that dislikes typing := when i would need to type it a lot, i can say that the me in that universe where Python was created with := would likely not be coding in Python. i'm not sure what i would be using. maybe still doing Pike. but it seems to have stalled out, at least in this universe. in both cases there is still a little C.
Apr-26-2021, 09:19 AM
I probably saved millions of times typing
:
with Python using = instead of :=! My main regret is that python uses .
instead of just a space character. Using a space makes typing code much more fluid.Apr-26-2021, 10:27 PM
typing : involves hold Shift on qwerty keyboards. that is the big reason i dislike typing := many times.
Apr-29-2021, 05:06 PM
Can't say it bothers me, having used it in Go and XQuery.
Apr-30-2021, 01:04 AM
> Can't say it bothers me, having used it in Go and XQuery
i don't even know what those are? are they terminal emulators?
i don't even know what those are? are they terminal emulators?
May-02-2021, 04:54 AM
No, they're programming languages: https://golang.org/ and e.g. https://en.m.wikipedia.org/wiki/XQuery.
Pages: 1 2