Skip to content

getattr

const getattr: <T>(obj: unknown, name: string, defaultValue?: T) => T | undefined = builtins.getattr

Defined in: packages/pythonlib/src/index.ts:193

Python getattr() function - get an attribute from an object

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
objunknownThe object to get the attribute from
namestringThe name of the attribute
defaultValue?TOptional default value if attribute doesn’t exist

Returns

T | undefined

The attribute value or default value