2014年11月9日

Python Study (4)– Dynamic type


Introduction

In many programs, You need to declare data type to tell compiler, but  you don’t do it  in Python. It are determined automatically at runtime. 

>>> a = “hellow ”    # without delcaring data type
          

Assigning variable 
1. Create an object
2. Create an variable
3. Create reference variable to object


Example :
The example create a variable and named “a”, then assign enough space to the object. the variable link to the object as reference.

>>> a = “hellow ”    
          
image


Example:
The float object is value 1.2 and tell python the object is a float-point-number at first assignment.

>>> a =  1.2          # first assign
>>> a =  2             # second reassign
>>> a =  ”apple”  # third reassign
          

沒有留言:

張貼留言