3

I just want to know how python's (python 2.7) interpreter is find the type of variable. Like How python Dynamic Type Behaviour internally works.

MacBook-Pro:~ neelabhsingh$ python Python 2.7.12 (default, Jun 29 2016, 14:05:02) >>> type(i) <type 'int'> >>> type(str1) <type 'str'> >>> testFloat = 45.67 >>> type(testFloat) <type 'float'> 
2
  • Which particular implementation? CPython 2.7 or 3.4? Or others; PyPy, Jython, IronPython, etc? Commented Aug 24, 2016 at 3:39
  • @PeterWood, Python 2.7.12 Commented Aug 24, 2016 at 3:43

1 Answer 1

4

In CPython 2.7 (i.e. the C language implementation of Python), there is a PyObject type. There is also a PyObject_Type function which accesses the type stored in the PyObject i.e. the object carries around type information with it.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.