[Tutor] DATA TYPES

Kent Johnson kent37 at tds.net
Thu Feb 21 13:04:20 CET 2008


Toby wrote:
> What I'm saying is if I have used a certain variable to hold literally
> dozens of different values and I BELIEVE them all to be integers but I'm not
> entirely sure that I have not stumbled into the float realm is there a way
> to have python list all variables contained in a program and tell me what
> type it has internally stored them as?  I realize I could trudge through the
> entire 1000 lines and check all the variables and see what values I have
> assigned them one at a time but I'm wondering if there is an easier way to
> get that data?

Isn't this exactly the kind of problem static typing is supposed to help 
with? If you write
   int i;
   i = 3.0;

you will get a compile-time error I think. So just make your best guess 
and then let the compiler find your errors.

Kent



More information about the Tutor mailing list