[Tutor] Reformatting phone number
dotancohen at gmail.com
Thu Aug 21 00:39:47 CEST 2008
2008/8/21 Alan Gauld <alan.gauld at btinternet.com>:
> "Dotan Cohen" <dotancohen at gmail.com> wrote
>> know if this is the case. Can I declare a variable type in Python as
>> in C?
> In Python values have types and variables are simply
> names associated with values.
> v = '123' # v 'is' a string because '123' is a string
> v = 123 # now v 'is' an int because 123 is an int.
> The variable takes on the type of the value with which it is
> associated but it can be made to refer to any other value
> and thus its type effectively changes. So it's best not to
> think of variables having types but rather consider objects
> (or values) as having a type, and variables as being
> associated with objects..
> This is one of the most fundamental characteristics of
> Python and one of the hardest for users of other languages
> to adapt to.
This characteristic is similar enough to php (a language where one
doesn't even think about types) that I will get used to it. Thanks.
More information about the Tutor