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

Is yield a keyword in python?

437


What is the output of the following?

451


Explain me what are the principal differences between the lambda and def?

462


What is dogpile mechanism? Explain.

546


What is the most "pythonic" way to iterate over a list in chunks?

453






How to copy an object in python?

431


Can python be used for web client and web server side programming?

443


Which methods/functions do we use to determine the type of instance and inheritance?

470


Mention the floor division available in python

437


Can a class extend itself?

450


Do you know how memory is managed in python?

452


What are the differences in list and tuple?

463


Describe about the libraries of python?

497


Is python better than ruby?

419


How will you share global variables across modules?

472