Scroll Down to See All▾
absaiterallanextanyasciibinboolbreakpointbytearraybytescallablechrcompilecomplexdelattrdictdivmodenumerateevalexecfilterfloatformatfrozensetgetattrglobalshasattrhashhelphexidinputintisinstanceissubclassiterlenlistlocalsmapmaxmemoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsumsupertupletypevarszip__import__clear_(dict)clear_(list)clear_(set)copy_(dict)copy_(list)copy_(set)fromkeysgetitemskeyspop_(dict)pop_(list)pop_(set)popitemsetdefaultupdatevaluescount_(tuple)count_(list)count_(str)index_(tuple)index_(list)index_(str)adddifferencedifference_updatediscardintersectionintersection_updateisdisjointissubsetissupersetremove_(set)remove_(list)symmetric_differencesymmetric_difference_updateunionupdateclosefilenoflushisattyreadreadablereadlinereadlinesseekseekabletelltruncatewritablewritewritelinesappendextendinsertreversesortcapitalizecasefoldcenterencodeendswithexpandtabsfindformatisalnumisalphaisasciiisdecimalisdigitisidentifierislowerisnumericisprintableisspaceistitleisupperjoinljustlowerlstripmaketranspartitionreplacerfindrindexrjustrpartitionrsplitrstripsplitsplitlinesstartswithstripswapcasetitletranslateupperdirzfillFunction Details: classmethod
Description
Transforms a method into a class method.
Extended Description
The classmethod() function is a decorator that transforms a method into a class method. Unlike a regular method, a class method receives the class as an implicit first argument, instead of an instance. This can be useful for defining alternative constructors or methods that operate on the class itself rather than instances.
Read More about classmethod from Python Documentation
Function Signature
classmethod(function: Callable) -> classmethod
Module: builtins
Parameters
function: A callable that will be transformed into a class method.
Parameter List
- function: Callable
Return
Returns a class method for the given function.
Return Type
classmethod
Output
Explanation
This example demonstrates a common use of classmethod as an alternative constructor.