Jump to content

Python: Difference between revisions

63 bytes added ,  23 October 2020
no edit summary
No edit summary
Line 300: Line 300:
</syntaxhighlight>
</syntaxhighlight>


==classes==
==Classes==


===Static and Class methods===
===Static and Class methods===
Line 347: Line 347:
* <code>len(os.sched_getaffinity(0))</code> returns the number of threads available to the Python process
* <code>len(os.sched_getaffinity(0))</code> returns the number of threads available to the Python process
* Starting in Python 3.5, if <code>max_workers</code> is none, it defaults to 5 times the number of threads on the system.
* Starting in Python 3.5, if <code>max_workers</code> is none, it defaults to 5 times the number of threads on the system.
==Classes==
<syntaxhighlight lang="python">
class Car:
  def __init__(self):
</syntaxhighlight>


==Data Structures==
==Data Structures==
Line 420: Line 414:
   print(k, v)
   print(k, v)
</syntaxhighlight>
</syntaxhighlight>
==Numpy==
===random===
Legacy code uses functions from <code>np.random.</code>.
New could should initialize a rng using <code>np.random.default_rng()</code>.


==Anaconda==
==Anaconda==