A certainl part of an if() structure never gets executed.
Denis McMahon
denismfmcmahon at gmail.com
Sun Jun 16 02:32:49 EDT 2013
On Sat, 15 Jun 2013 19:18:53 +0300, Nick the Gr33k wrote:
> In both situations we still have 2 memory units holding values, so hows
> that different?
Consider that each named variable is a pointer to a memory location that
holds a value. This is one of the ways in that a typed compiled language
and an untyped scripted language may differ in their treatment of data
items (or variables).
Consider the following C and Python code:
C:
int a, b;
b = 6;
a = b;
In C, this places the numeric value 6 into the memory location identified
by the variable "b", then copies the value from the location pointed to
by "b" into the location pointed to by "a".
b is a pointer to a memory location containing the value 6
a is a pointer to another memory location also containing the value 6
Python:
b = 6
a = b
In Python, this first puts the value 6 in in a memory location and points
"b" at that memory location, then makes "a" point to the same memory
location as "b" points to.
b is a pointer to a memory location containing the value 6
a is a pointer to the same memory location
Do you understand the difference?
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list