Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

python_typing_practice

example

import typing

def hello_world(message:typing.Union[str, typing.List[str]]="Hello world!"):
    if isinstance(message, str):
        print(message)
    elif isinstance(message, list):
        for sentence in message:
            print(sentence)
    else:
        raise TypeError('The type of message parameter should be str or List[str], \
                        found:',type(message))

from python 3.10, it is possible to use " | " instead of typing.Union :

...

def hello_world(message:str|typing.List[str]="Hello world!"):

...

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors