On Sat, 18 Jan 2020 at 02:32, Josh Rosenberg
wrote:
>
> The colon remains syntactically necessary in some cases, particularly to
> disambiguate cases involving one-lining (no block involved). Stupid example:
> If the colon is optional, what does:
>
> if d +d
>
> mean? Is it a test of the value o
This is more of a doubt than a new idea. Python has always worked
intuitively but this was a bummer.
A list has an append method. So I can do list.append(value).
I tried doing list(range(10)).append(10) and it returns None. I'd usually
assume list(range(10)) returns a list, to which I can append w
[M Siddharth Prajosh ]
> This is more of a doubt than a new idea. Python has always worked
> intuitively but this was a bummer.
>
> A list has an append method. So I can do list.append(value).
> I tried doing list(range(10)).append(10) and it returns None.
Yes. Most methods that mutate an object
On Sun, Jan 19, 2020 at 2:45 PM Siddharth Prajosh wrote:
>
> Moreover, shouldn't it work?
> How do I add that feature in Python?
How you can do it with warus operator.
>>> (xs := list(range(10))).append(42)
>>> xs
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 42]
Regards,
--
Inada Naoki
__