Difference between revisions of "Python"
Jump to navigation
Jump to search
(Created page with "Python Tips and Tricks === Array enumeration === For numpy <syntaxhighlight lang="python" highlight="1,5-7"> a = np.array([[1, 2], [3, 4]]) for index, x in np.ndenumerate(...") |
|||
| Line 9: | Line 9: | ||
for index, x in np.ndenumerate(a): | for index, x in np.ndenumerate(a): | ||
print(index, x) | print(index, x) | ||
| − | </syntaxhighlight> === | + | </syntaxhighlight> |
| + | For usual python | ||
| + | <syntaxhighlight lang="python" highlight="1,5-7"> | ||
| + | a = np.array([[1, 2], [3, 4]]) | ||
| + | for index, x in enumerate(a): | ||
| + | print(index, x) | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | |||
| + | === Multiprocessing === | ||
Revision as of 20:42, 26 January 2023
Python Tips and Tricks
Array enumeration
For numpy
a = np.array([[1, 2], [3, 4]])
for index, x in np.ndenumerate(a):
print(index, x)
For usual python
a = np.array([[1, 2], [3, 4]])
for index, x in enumerate(a):
print(index, x)