Steven D'Aprano wrote:
On Thu, 28 Aug 2008 16:28:03 -0700, Paul McNett wrote:
[EMAIL PROTECTED] wrote:
x=[1,2,3]
and
x=[1,2,3,]
are exactly the same, right?
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
}}}
Putting on my pedantic hat...
In this case you're right about the two lists being the same, and I'm a
great believer in checking things in the interactive interpreter, but you
need to take care. Just because two objects compare as equal doesn't
*necessarily* mean they are the same:
True.
1.0 == 1
True
1.0 == decimal.Decimal('1.0')
False
1.0 == float(decimal.Decimal('1.0'))
True
These are comparing different types.
collections.defaultdict(999) == {}
True
I try this and get:
TypeError: first arument must be callable
Paul
--
http://mail.python.org/mailman/listinfo/python-list