Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"dict unpack" as it were a list values #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

x2es
Copy link

@x2es x2es commented Apr 15, 2022

When code like

return foo, bar, baz

Refactored to

return { 'foo': foo, 'bar': bar, 'baz': baz }

It's handy to refactor client part like:

++ from operator import itemgetter
-- foo, bar, baz = some_f()
++ foo, bar, baz = itemgetter('foo', 'bar', 'baz')(some_f())

When code like

```
return foo, bar, baz
```

Refactored to

```
return { 'foo': foo, 'bar': bar, 'baz': baz }
```

It's handy to refactor client part like:

```
-- foo, bar, baz = some_f()
++ foo, bar, baz = itemgetter('foo', 'bar', 'baz')(some_f())
```
@x2es
Copy link
Author

x2es commented Apr 15, 2022

I am not sure does it right place to the tip. I believe this page should refer to this tip at least.
Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant