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



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

Answer / 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

More Python Interview Questions

Which os is best for python?

0 Answers  


How do I convert a string to a number?

1 Answers  


Can you make a python executable?

0 Answers  


If you installed a module with pip but it doesn’t import in your idle, what could it possibly be?

0 Answers  


Explain whats flask?

0 Answers  






Can python be used for automation?

0 Answers  


Which all are the operating system that Python can run on?

0 Answers  


How multithreading is achieved in python?

0 Answers  


How to retrieve data from a table in mysql database through python code?

0 Answers  


What is the difference between cpython and python?

0 Answers  


Executing dml commands through python programs?

0 Answers  


Explain different ways to create an empty numpy array in python?

0 Answers  


Categories