On 07/07/2020 16:31, Henk-Jaap Wagenaar wrote:
I used to be in this "camp", however, a (I think valid) point was
raised that "else:" is not a (full) alternative. Due to the
restriction on repeated names (e.g. Point(x, x) is illegal), if you
want to "throw away" intermediate matches, you will have to either
have to come up with new names (Point(unused_1, unused_2)) or use the
"_" as currently instituted (Point(_, _)) and "else:" does not cover
that insofar as I can tell.
Personally I think using _ as throwaway name is perfectly fine, as it is
in the rest of Python. The only exception would then be that _ is
allowed to be repeated, whereas other identifiers aren't. I'd be ok with
that.
What I don't like is the use of _ as catch-all, which is different and
not interdependent with its use as throwaway.
On 08/07/2020 07:26, Steven Barker wrote:
To sum up, I feel like using constructor and keyword-argument syntax
to access attributes is an abuse of notation. I'd much prefer a new
syntax for matching classes and their attributes that was not so
likely to be confusing due to imperfect parallels with class construction.
+1
Ideally something like Datetime.year=x would be in my opinion clear at a
glance (and reference vs. assignment could be accomplished simply by
having == for reference and = for assignment), but it's problematic when
it comes to mentioning multiple attributes.
A couple ideas:
1. Datetime[year=x, months==3, days==SOME_CONST]
2. (Datetime.year=x, months==3, days==SOME_CONST)
3. Datetime.year=x .months==3 .days==SOME_CONST
4. Datetime.year=x, .months==3, .days==SOME_CONST
With no class, this would perhaps favour usage of = and/or == before
names to resolve the reference vs. assignment dispute.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/NGETVO36VD2ECR7Z7F5LYDUP62RRFKVU/
Code of Conduct: http://python.org/psf/codeofconduct/