Python: Difference between revisions

Line 309: Line 309:
===Static and Class methods===
===Static and Class methods===
See [https://realpython.com/instance-class-and-static-methods-demystified/ realpython]
See [https://realpython.com/instance-class-and-static-methods-demystified/ realpython]
Note that the Google Python style guide discourages use of static methods.
Class methods should only be used to define alternative constructors (e.g. fromMatrix).


<syntaxhighlight lang="python">
<syntaxhighlight lang="python">
Line 326: Line 323:
         return 'static method called'
         return 'static method called'
</syntaxhighlight>
</syntaxhighlight>
;Notes
* That the Google Python style guide discourages use of static methods.
** Class methods should only be used to define alternative constructors (e.g. from_matrix).


==Multithreading==
==Multithreading==