newbie: confused with example in Learning Python 2nd Edition: cananyone give a hint
Tue Aug 24 03:57:59 CEST 2004
"Robert Brewer" <fumanchu at amor.org> writes:
> > So: why defitions of self.push and self.pop are defined as
> > 'data.append' rather than '_data.append', etc.
It's an error. It should say _data.append.
> Hint: Python doesn't have variables like other languages do. The line:
> self._data = list(data)
> does not make a copy of "data". Instead, it binds a new name
> (self._data) to the same object which the name "data" refers to.
The list function does make a copy.
Python 2.3.4 (#1, Jul 24 2004, 19:45:58)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a is j
[9, 8, 2]
More information about the Python-list