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

Please explain in python what is slicing?

0 Answers  


Is python written in python?

0 Answers  


How many arguments can the range() function take?

0 Answers  


Are there any interfaces to database packages in python?

0 Answers  


What is python used for today?

1 Answers  






What is dictionary in python?

0 Answers  


Which python library would you prefer to use for data munging?

0 Answers  


Is r language hard?

0 Answers  


What are the tools that help to find bugs or perform the static analysis?

0 Answers  


How do you sort a list in ascending order in python?

0 Answers  


How do I run a python script in windows?

0 Answers  


What is step size in python?

0 Answers  


Categories