[Tutor] How python keeps track of data types

Danny Yoo dyoo at hashcollision.org
Tue Mar 29 03:23:37 EDT 2016


Hi Abhishek,

On Mon, Mar 28, 2016 at 12:31 PM, Abhishek Kumar
<abhishekkmr18 at gmail.com> wrote:
> Hello
> I am a computer science student,I want to know how python keeps track of
> data types of variables and is there a way to get data types of variables
> without actually running the script(with type() function). I think python
> AST can help, but am unable to figure out.Please help me.
> I've explored compiler library but could not find anything helpful.


This is not a beginner-level question.  You may not be reaching the
audience you want here.  You're essentially asking for a static type
system for Python.  Python was not particularly designed to
accommodate a static type system  It is dynamically typed: in Python,
types are attached to values, not variables.

Start reading:

https://en.wikipedia.org/wiki/Type_system#Dynamic_type_checking_and_runtime_type_information


Your question is an active area of CS research.  Therefore, we can't
provide clear, direct answers to your question: you have to do your
own searching.  Here are a few starting points.

    http://lambda-the-ultimate.org/node/1519

    http://lambda-the-ultimate.org/node/2622

    https://www.cis.upenn.edu/~bcpierce/tapl/


More information about the Tutor mailing list