0 votes
in Python by (30.6k points)
What is the procedure to extract values from the object used in python?

1 Answer

0 votes
by (30.6k points)

To extract the value it requires the object type to be defined and the values are fetched according to the object type.

The values are extracted as:

- If the object is a tuple then PyTuple_Size() method is used that returns the length of the values and the method PyTuple_GetItem() returns the data item stored at a specific index.

- If the object is a list then PyListSize() and PyList_GetItem() perform the same function as they are for tuple.

- Strings use PyString_Size() to return the length of the value and PyString_AsString() returns the pointer to its value.

- To check the type of the object and the extracted values, methods like PyString_Check(), PyTuple_Check(), PyList_Check(), etc are used.

Related questions