You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cheatsheet.md
+75Lines changed: 75 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -296,6 +296,81 @@ len(<dict>) # Find the length of the diction
296
296
297
297
A dictionary can also contain many dictionaries, this is called nested dictionaries.
298
298
299
+
### Dictionary unpacking
300
+
301
+
A double asterisk `**` denotes dictionary unpacking. Its operand must be a mapping. Each mapping item is added to the new dictionary. Later values replace values already set by earlier dict items and earlier dictionary unpackings.
302
+
303
+
Originally proposed by [PEP 448](https://peps.python.org/pep-0448/).
"""Prints the ingredients of a customized sandwich."""
313
+
314
+
sandwich =f"A {protein} sandwich"
315
+
316
+
if cheese:
317
+
sandwich +=f" with {cheese}"
318
+
319
+
if sauce:
320
+
sandwich +=f" and {sauce} on it"
321
+
322
+
if extras:
323
+
sandwich +=f" (plus {extras})"
324
+
325
+
print(sandwich)
326
+
```
327
+
328
+
329
+
2. Define the Configuration Dictionary
330
+
331
+
We create a **dictionary** where the **keys** match the **keyword argument names** of the function (`protein`, `cheese`, `sauce`, etc.).
332
+
333
+
```python
334
+
# Our sandwich configuration stored in a dictionary
335
+
sandwich_settings = {
336
+
'protein': 'turkey',
337
+
'cheese': 'provolone',
338
+
'sauce': 'mayo',
339
+
'extras': 'lettuce and tomato'
340
+
}
341
+
```
342
+
343
+
3. Use the Unpacking Operator (`**`)
344
+
345
+
We call the function and use `**` to unpack the dictionary. The `**` operator turns the dictionary's key-value pairs into individual keyword arguments.
346
+
347
+
```python
348
+
# Unpack the dictionary into keyword arguments
349
+
make_sandwich(**sandwich_settings)
350
+
```
351
+
352
+
**Output:**
353
+
354
+
```
355
+
A turkey sandwich with provolone and mayo on it (plus lettuce and tomato)
356
+
```
357
+
358
+
**What the `**` Does**
359
+
360
+
The line `make_sandwich(**sandwich_settings)` is functionally equivalent to writing:
361
+
362
+
```python
363
+
make_sandwich(
364
+
protein='turkey',
365
+
cheese='provolone',
366
+
sauce='mayo',
367
+
extras='lettuce and tomato'
368
+
)
369
+
```
370
+
371
+
The `**` operator is a clean way to pass a dynamic or pre-configured set of arguments to a function.
372
+
373
+
299
374
### Tuple
300
375
301
376
A tuple is a collection which is ordered, indexed and unchangeable. In Python tuples are written with round brackets.
{octicon}`smiley;1em;caption-text`**A Whirlwind Tour of Python**
11
+
{octicon}`megaphone;1em;caption-text`**A Whirlwind Tour of Python**
12
12
^^^
13
13
A Whirlwind Tour of Python is a fast-paced introduction to essential features of the Python language, aimed at researchers and developers who are already familiar with programming in another language.
14
14
+++
@@ -18,7 +18,7 @@ A Whirlwind Tour of Python is a fast-paced introduction to essential features of
An exercise-driven course on Advanced Python Programming that was battle-tested several hundred times on the corporate-training circuit for more than a decade. Written by David Beazley.
24
24
+++
@@ -28,7 +28,7 @@ An exercise-driven course on Advanced Python Programming that was battle-tested
Inside the Python Virtual Machine provides a guided tour under the covers of the Python interpreter for the curious pythonista. It attempts to show the user what happens from the moment the user executes a piece of Python code to the point when the interpreter returns the result of executing the piece of code.
78
+
+++
79
+
[Read more or use this reference »](https://leanpub.com/insidethepythonvirtualmachine/read)
{octicon}`pencil;1em;caption-text`**Python & OpenGL for Scientific Visualization**
115
+
{octicon}`checklist;1em;caption-text`**Python & OpenGL for Scientific Visualization**
102
116
^^^
103
117
he goal of this book is to reconciliate Python programmers with OpenGL, providing both an introduction to modern OpenGL and a set of basic and advanced techniques in order to achieve both fast, scalable & beautiful scientific visualizations.
104
118
+++
@@ -108,7 +122,7 @@ he goal of this book is to reconciliate Python programmers with OpenGL, providin
{octicon}`briefcase;1em;caption-text`**Python Programming for Economics and Finance**
155
+
{octicon}`file;1em;caption-text`**Python Programming for Economics and Finance**
142
156
^^^
143
157
Python for scientific computing, with a focus on economics and finance.
144
158
+++
@@ -148,7 +162,7 @@ Python for scientific computing, with a focus on economics and finance.
148
162
149
163
:::{grid-item-card}
150
164
:link:https://wesmckinney.com/book/
151
-
{octicon}`note;1em;caption-text`**Python for Data Analysis, 3E**
165
+
{octicon}`stack;1em;caption-text`**Python for Data Analysis, 3E**
152
166
^^^
153
167
This book is concerned with the nuts and bolts of manipulating, processing, cleaning, and crunching data in Python.
154
168
+++
@@ -158,7 +172,7 @@ This book is concerned with the nuts and bolts of manipulating, processing, clea
158
172
159
173
:::{grid-item-card}
160
174
:link:https://goodresearch.dev/
161
-
{octicon}`telescope;1em;caption-text`**The Good Research Code Handbook**
175
+
{octicon}`pencil;1em;caption-text`**The Good Research Code Handbook**
162
176
^^^
163
177
Handbook is for all who do a lot of programming as part of their research. It will teach you, in a practical manner, how to organize your code so that it is easy to understand and works reliably.
164
178
+++
@@ -168,7 +182,7 @@ Handbook is for all who do a lot of programming as part of their research. It wi
168
182
169
183
:::{grid-item-card}
170
184
:link:https://docs.python-guide.org/
171
-
{octicon}`tag;1em;caption-text`**The Hitchhiker’s Guide to Python**
185
+
{octicon}`hubot;1em;caption-text`**The Hitchhiker’s Guide to Python**
172
186
^^^
173
187
Python Best Practices Guidebook.
174
188
+++
@@ -178,7 +192,7 @@ Python Best Practices Guidebook.
Copy file name to clipboardExpand all lines: generatedfiles/commercialcompanies.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
:::{grid-item-card}
10
10
:link:https://www.anaconda.com/
11
-
{octicon}`bookmark;1em;caption-text`**Anaconda**
11
+
{octicon}`stack;1em;caption-text`**Anaconda**
12
12
^^^
13
13
Anaconda sits at the center of the AI revolution. We provide data science tools, MLOps, and data & model management to empower our customers and community with AI capabilities to propel their projects forward.
14
14
+++
@@ -18,7 +18,7 @@ Anaconda sits at the center of the AI revolution. We provide data science tools,
The Documentation Team will be contributors to documentation who participate regularly to CPython documentation and monthly meetings (synchronously or asynchronously). A goal of this team will be to build a global community around CPython documentation.
54
54
+++
@@ -58,7 +58,7 @@ The Documentation Team will be contributors to documentation who participate reg
The scientific Python ecosystem is a loose federation of community-developed and -owned Python projects widely used in scientific research, technical computing, and data science.
Copy file name to clipboardExpand all lines: generatedfiles/foundations.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@
8
8
9
9
:::{grid-item-card}
10
10
:link:https://numfocus.org/
11
-
{octicon}`project;1em;caption-text`**NumFOCUS**
11
+
{octicon}`tools;1em;caption-text`**NumFOCUS**
12
12
^^^
13
13
NumFOCUS is to promote open practices in research, data, and scientific computing
14
14
+++
@@ -17,7 +17,7 @@ NumFOCUS is to promote open practices in research, data, and scientific computin
17
17
18
18
19
19
:::{grid-item-card}
20
-
{octicon}`hubot;1em;caption-text`**WheelNext**
20
+
{octicon}`project;1em;caption-text`**WheelNext**
21
21
^^^
22
22
WheelNext is an open-source initiative (https://github.com/wheelnext & https://wheelnext.dev/) aiming to improve the user experience in the Python packaging ecosystem, specifically around the scientific computing and machine/deep learning space. We also anticipate benefits in other domains that heavily rely on performance of compiled Python extension modules - the benefit of utilizing one's hardware more optimally is not exclusive to any single domain.
23
23
+++
@@ -27,7 +27,7 @@ WheelNext is an open-source initiative (https://github.com/wheelnext & https://w
0 commit comments