On 12/05/2018 23:52, Neil Girdhar wrote:


On Sat, May 12, 2018 at 5:54 PM Cameron Simpson <[email protected] <mailto:[email protected]>> wrote:

    On 06May2018 02:00, Nick Coghlan <[email protected]
    <mailto:[email protected]>> wrote:
    >On 5 May 2018 at 13:36, Tim Peters <[email protected]
    <mailto:[email protected]>> wrote:
    >> If only one trailing "given" clause can be given per `if` test
    >> expression, presumably I couldn't do that without trickery.
    >
    >I was actually thinking that if we did want to allow multiple
    assignments,
    >and we limited targets to single names, we could just use a comma
    as a
    >separator:
    >
    >    if diff and g > 1 given diff = x - x_base, g = gcd(diff, n):
    >        return g
    >
    >Similar to import statements, optional parentheses could be
    included in the
    >grammar, allowing the name bindings to be split across multiple
    lines:
    >
    >    if diff and g > 1 given (
    >        diff = x - x_base,
    >        g = gcd(diff, n),
    >    ):
    >        return g

    I'm well behind, but... this! This turns "given" into a +0.8 for me.

    That's really nice. It reads clearly too.

    I was hitherto in the "expression as name" camp, which I gather is
    already
    rejected.


I love given, but that's the one thing I don't like.  I prefer this:
    if (diff and g > 1
            given diff = x - x_base
            given g = gcd(diff, n)):
        return g

I don't like the consecutive "given"s.  Reading it aloud in English suggests to me that the second "given" should be evaluated before the first, which I'm sure is not the intention. (Just as I think that multiple for-loops inside a comprehension sound the wrong way round. :-( But that ship has sailed.)
Rob Cliffe
—just like for and if subexpressions.   Doing this can also open up weirdness if someone tries to roll something like:

a = f(),  # Make a tuple of length 1

into a given statement.  Now, where do you up the parentheses?

given (
    a = (f(),),
    b = whatever?
)

Seems weird.


    Cheers,
    Cameron Simpson <[email protected] <mailto:[email protected]>>
    _______________________________________________
    Python-ideas mailing list
    [email protected] <mailto:[email protected]>
    https://mail.python.org/mailman/listinfo/python-ideas
    Code of Conduct: http://python.org/psf/codeofconduct/

--
    ---
    You received this message because you are subscribed to a topic in
    the Google Groups "python-ideas" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/python-ideas/CFuqwmE8s-E/unsubscribe.
    To unsubscribe from this group and all its topics, send an email
    to [email protected]
    <mailto:python-ideas%[email protected]>.
    For more options, visit https://groups.google.com/d/optout.


<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Virus-free. www.avg.com <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to