On Sun, 16 Jun 2013 11:07:12 +0300, Nick the Gr33k wrote: > On 16/6/2013 9:32 πμ, Denis McMahon wrote: >> 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? >> > Yes and thank you for explaining in detail to me. > So Python economies(saves) system's memory. Good job Python!
No. Don't read that into it. For example, in Python a = 6 b = a c = 6 a and b point to one memory location that contains the value 6 c points to a different memory location that contains the value 6 Python doesn't point all the variables that have the same value at the same location. > A pointer = a variable that has as a value a memory address a variable = > a memory address that has as a value the actual value we want to store. These are really C terms, not Python terms. Stop thinking that C is behaving like Python. > Is this how the thing works? No. Python is an interpreted language. C is a compiled language. They present very different feature sets to the user. You need to understand this, and at the moment you're not doing so. -- Denis McMahon, denismfmcma...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list