Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

staticmethod python

import random

class Example:
  	# A static method doesn't take the self argument and
    # cannot access class members.
	@staticmethod
    def choose(l: list) -> int:
    	return random.choice(l)
    
    def __init__(self, l: list):
      self.number = self.choose(l)
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #staticmethod #python
ADD COMMENT
Topic
Name
2+4 =