[1,2,3] exactly same as [1,2,3,] ?
James Mills
prologic at shortcircuit.net.au
Thu Aug 28 19:35:10 EDT 2008
- Previous message (by thread): [1,2,3] exactly same as [1,2,3,] ?
- Next message (by thread): [1,2,3] exactly same as [1,2,3,] ?
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
On Fri, Aug 29, 2008 at 9:28 AM, Paul McNett <p at ulmcnett.com> wrote:
> When confronted with this type of question, I ask the interpreter:
>
> {{{
> mac:~ pmcnett$ python
> Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
> [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
>>>> [1,2,3] == [1,2,3,]
> True
> }}}
I must point out though that although they contain
the same elements/data, they are not the same
object/instance.
{{{
#!python
>>> x = [1, 2, 3]
>>> y = [1, 2, 3]
>>> id(x)
3083095148L
>>> id(y)
3082953324L
>>> x == y
True
}}}
If you view the documentation for a list:
{{{
#!sh
$ pydoc list
}}}
list's have an __eq__ that is used to compare the
equality of 2 lists.
cheers
James
--
--
-- "Problems are solved by method"
- Previous message (by thread): [1,2,3] exactly same as [1,2,3,] ?
- Next message (by thread): [1,2,3] exactly same as [1,2,3,] ?
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Python-list
mailing list