Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python template generics

from typing import TypeVar, Generic

T = TypeVar('T')

class Stack(Generic[T]):
    def __init__(self) -> None:
        # Create an empty list with items of type T
        self.items: List[T] = []

    def push(self, item: T) -> None:
        self.items.append(item)

    def pop(self) -> T:
        return self.items.pop()

    def empty(self) -> bool:
        return not self.items
Comment

PREVIOUS NEXT
Code Example
Python :: python image black and white 
Python :: pandas sort values by multiple columns 
Python :: waitkey in opencv 
Python :: opposite of .isin pandas 
Python :: min max scaling pandas 
Python :: ubuntu install pip for python 3.8 
Python :: ax set xtick size 
Python :: python get current time in hours minutes and seconds 
Python :: python product of list 
Python :: python format to print dec oct hex and bin 
Python :: Python program to check leap year or not? 
Python :: how to check if its later than python 
Python :: py exe tkinter 
Python :: loading text file delimited by tab into pandas 
Python :: unique words from pandas 
Python :: pandas replace nulls with zeros 
Python :: goal parser 
Python :: how to create notification in python 
Python :: take off character in python string 
Python :: python class get attribute by name 
Python :: how to add and subtract days datetime python 
Python :: insert video in tkinter 
Python :: python sum comprehension 
Python :: get client ip flask 
Python :: simple thresholding with OpenCV 
Python :: pandas drop rows with empty list 
Python :: python set current working directory to script location python 
Python :: how to code in python 
Python :: subtract one list from another python 
Python :: python invert dictionary 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =