What is the procedure to extract values from the object used in python?

Answer Posted / chaitanya

To extract the value it requires the object type to be defined and according to the object type only the values will be fetched. The values will be extracted as:

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

• If the object is a list then PyListSize() is having the same function that is defined for the tuple and PyList_GetItem() that also return the data items at a specified index.

• Strings uses PyString_Size() to return the length of the value and PyString_AsString() that return the pointer to its value.

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

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain supported data types in python?

450


Can we use singleton functionality without making a singleton class in Python?

483


Is python completely free?

440


Write a small code to explain repr() in python ?

492


What is python interpreter?

459






Tell me what is docstring in python?

447


Why is the order in python dictionaries and sets arbitrary?

533


What is data type set in python and how to work with it?

446


How do you comment in python?

437


Should I learn python before c?

454


Why is python used?

417


What is a raw string in python?

442


What is python main function and write one good example?

479


What is variable length argument in function?

488


Explain when is the python decorator used?

462