<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, 9 Apr 2018 at 05:18 Joao S. O. Bueno <<a href="mailto:jsbueno@python.org.br">jsbueno@python.org.br</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have an idea for an inovative, unanbiguous, straightforward and<br>
backwards compatible syntax for that,<br>
that evena llows one to pass metadata along the operation so that the<br>
results can be tweaked acording<br>
to each case's needs.<br>
<br>
What about:<br>
<br>
new_data = dict_feed({<br>
        "direct": "some data",<br>
        "nested": {<br>
            "lst_data": [1, 2, 3],<br>
            "int_data": 1<br>
        }<br>
    },<br>
data<br>
)<br>
<br>
we could even call this approach a name such as "function call".<br></blockquote><div><br></div><div>The harsh sarcasm is not really called for.<br><br></div><div>-Brett<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
In other words, why to bloat the language with hard to learn, error prone,<br>
grit-looking syntax, when a simple plain function call is perfectly<br>
good, all you need to do over<br>
your suggestion is to type the function name and a pair of parentheses?<br>
<br>
<br>
<br>
<br>
On 7 April 2018 at 14:26, thautwarm <<a href="mailto:yaoxiansamma@gmail.com" target="_blank">yaoxiansamma@gmail.com</a>> wrote:<br>
> We know that Python support the destructing of iterable objects.<br>
><br>
> m_iter = (_ for _ in range(10))<br>
> a, *b, c = m_iter<br>
><br>
> That's pretty cool! It's really convenient when there're many corner cases<br>
> to handle with iterable collections.<br>
> However destructing in Python could be more convenient if we support<br>
> dictionary destructing.<br>
><br>
> In my opinion, dictionary destructing is not difficult to implement and<br>
> makes the syntax more expressive. A typical example is data access on nested<br>
> data structures(just like JSON), destructing a dictionary makes the logic<br>
> quite clear:<br>
><br>
> data = {<br>
>     "direct": "some data",<br>
>     "nested": {<br>
>         "lst_data": [1, 2, 3],<br>
>         "int_data": 1<br>
>     }<br>
> }<br>
> {<br>
>    "direct": direct,<br>
>     "nested": {<br>
>         "lst_data": [a, b, c],<br>
>     }<br>
> } = data<br>
><br>
><br>
> Dictionary destructing might not be very well-known but it really helps. The<br>
> operations on nested key-value collections are very frequent, and the codes<br>
> for business logic are not readable enough until now. Moreover Python is now<br>
> popular in data processing which must be enhanced by the entire support of<br>
> data destructing.<br>
><br>
> Here are some implementations of other languages:<br>
> Elixir, which is also a popular dynamic language nowadays.<br>
><br>
> iex> %{} = %{:a => 1, 2 => :b}<br>
> %{2 => :b, :a => 1}<br>
> iex> %{:a => a} = %{:a => 1, 2 => :b}<br>
> %{2 => :b, :a => 1}<br>
> iex> a<br>
> 1<br>
> iex> %{:c => c} = %{:a => 1, 2 => :b}<br>
> ** (MatchError) no match of right hand side value: %{2 => :b, :a => 1}<br>
><br>
> And in F#, there is something similar to dictionary destructing(actually,<br>
> this destructs `struct` instead)<br>
> type MyRecord = { Name: string; ID: int } let IsMatchByName record1 (name:<br>
> string) = match record1 with | { MyRecord.Name = nameFound; MyRecord.ID = _;<br>
> } when nameFound = name -> true | _ -> false let recordX = { Name =<br>
> "Parker"; ID = 10 } let isMatched1 = IsMatchByName recordX "Parker" let<br>
> isMatched2 = IsMatchByName recordX "Hartono"<br>
><br>
> All of them partially destructs(or matches) a dictionary.<br>
><br>
> thautwarm<br>
><br>
><br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
><br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div>