Difference between revisions of "Python"

From Quantum kot
Jump to navigation Jump to search
Line 19: Line 19:
  
 
=== Multiprocessing ===
 
=== Multiprocessing ===
 +
 +
 +
 +
=== Context ===

Revision as of 20:58, 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)


Multiprocessing

Context