On Sun, Apr 19, 2020, 10:16 PM Steven D'Aprano <st...@pearwood.info> wrote:

> > Understand that I'm not really advocating for a magic function like
> Q().  I
> > think it's important to keep in mind that anyone COULD create such a
> thing
> > for 20 years, and very few people bothered to.
>
> You don't really know how many people are using such a thing in their
> private code.


I've read quite a bit of open source code and code at places I've worked. I
think "very few" is a safe claim. It's more than "none."

At least with a language feature, the hack is official, and it's the
> responsibility of the language devs to keep it working, at which point it
> ceases to be a hack and becomes just part of the language.
>

I see you're point here. Q(), or the improved M(), are certainly not more
magic than namedtuple, or typing, or dataclass, or @total_ordering. But
those are parts of the official language, and we can trust that edge cases
and bugs will be well addressed in every release.

Attrs is pretty magic, and also widely used... But after a while, that
motivated dataclass, which is largely similar, to be added to the official
language. Popular packages like Django or Pandas have a fair amount of
magic in them, but that magic is specific to working with the objects they
create.

I do recognize that Q() or M() or Alex's dict_of() break the rules of what
functions are supposed to do. Python is pass-by-reference not pass-by-name,
and these deliberately muck with that.

So you've moved me a bit towards the side of wanting a new DICT DISPLAY.
Something completely limited to calling form feels artificially limited for
no reason. And the addition of f"{foo=}" is very similar magic for similar
reasons.

So constructing a dictionary like these are only -0 for me (maybe -0.1):

dct = {**, foo, bar, baz}
dct = **{foo, bar, baz}
dct = {foo=, bar=, baz=}

With any of those corresponding in function calls:

fun(**kws, foo, bar, baz)
fun(**, foo, bar, baz)
fun(**kws, **{foo, bar, baz})
fun(**kws, foo=, bar=, baz=)

The form with the dangling equal signs still strikes me as horribly ugly,
but I see the closer analogy with the f-string magic.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/37IZURMADBWSAHAWROFRD7S5ISQA5NU4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to