types
import types
Provides type validation and conversion capabilities
This module is wrapper around the builtin functions where applicable and does and return the same thing as the builtin alternative.
The types API
Every public name in types, wherever it is declared. Each links to the
page that documents it.
| Name | Kind | Summary |
|---|---|---|
types.alpha | function | Returns true if the value is a character and alphabetic, otherwise returns false. |
types.bool | function | Returns true if the value is a boolean or false otherwise. |
types.bytes | function | Returns true if the value is a bytes or false otherwise. |
types.callable | function | Returns true if the value is a callable function or class and false otherwise. |
types.char | function | Returns true if the value is a single character or false otherwise. |
types.dict | function | Returns true if the value is a dictionary or false otherwise. |
types.digit | function | Returns true if the value is a character and digit, otherwise returns false. |
types.file | function | Returns true if the value is a file or false otherwise. |
types.function | function | Returns true if the value is a function or false otherwise. |
types.instance | function | Returns true if the value is an instance the given class, false otherwise. |
types.int | function | Returns true if the value is an integer or false otherwise. |
types.is_a_class | function | Returns true if the value is a class or false otherwise. |
types.iterable | function | Returns true if the value is an iterable or false otherwise. |
types.list | function | Returns true if the value is a list or false otherwise. |
types.number | function | Returns true if the value is a number or false otherwise. |
types.object | function | Returns true if the value is an object or false otherwise. |
types.of | function | Returns the name of the type of value |
types.string | function | Returns true if the value is a string or false otherwise. |
Functions
of()
types.of(value) -> string
Returns the name of the type of value
Parameters
value(any)
Returns string
Note: method implemented as part of core language features
digit()
types.digit(value: string) -> bool
Returns true if the value is a character and digit, otherwise returns false.
Parameters
value(string)
Returns bool
alpha()
types.alpha(value: string) -> bool
Returns true if the value is a character and alphabetic, otherwise returns false.
Parameters
value(string)
Returns bool
int()
types.int(value) -> bool
Returns true if the value is an integer or false otherwise.
Parameters
value(any)
Returns bool
bool()
types.bool(value) -> bool
Returns true if the value is a boolean or false otherwise.
Parameters
value(any)
Returns bool
number()
types.number(value) -> bool
Returns true if the value is a number or false otherwise.
Parameters
value(any)
Returns bool
Note: this method also returns true for integers.
char()
types.char(value) -> bool
Returns true if the value is a single character or false otherwise.
Parameters
value(any)
Returns bool
string()
types.string(value) -> bool
Returns true if the value is a string or false otherwise.
Parameters
value(any)
Returns bool
bytes()
types.bytes(value) -> bool
Returns true if the value is a bytes or false otherwise.
Parameters
value(any)
Returns bool
list()
types.list(value) -> bool
Returns true if the value is a list or false otherwise.
Parameters
value(any)
Returns bool
dict()
types.dict(value) -> bool
Returns true if the value is a dictionary or false otherwise.
Parameters
value(any)
Returns bool
object()
types.object(value) -> bool
Returns true if the value is an object or false otherwise.
Parameters
value(any)
Returns bool
function()
types.function(value) -> bool
Returns true if the value is a function or false otherwise.
Parameters
value(any)
Returns bool
is_a_class()
types.is_a_class(value) -> bool
Returns true if the value is a class or false otherwise.
Parameters
value(any)
Returns bool
file()
types.file(value) -> bool
Returns true if the value is a file or false otherwise.
Parameters
value(any)
Returns bool
iterable()
types.iterable(value) -> bool
Returns true if the value is an iterable or false otherwise.
Parameters
value(any)
Returns bool
callable()
types.callable(value) -> bool
Returns true if the value is a callable function or class and false otherwise.
Parameters
value(any)
Returns bool
instance()
types.instance(value, type: type) -> bool
Returns true if the value is an instance the given class, false otherwise.
Parameters
value(any)type(type)
Returns bool
2021, Richard Ore and Zuri contributors