Fixed mx.DateTime or alternative?
Chris Barker
chrishbarker at home.net
Mon Jul 9 14:53:57 EDT 2001
"M.-A. Lemburg" wrote:
> > >>> from mx import DateTime
> > >>> dt = DateTime.now()
> > >>> if dt==None: print 1
>
> Side note:
>
> if x is None: ...
>
> is a possible workaround which is faster than using "==" !
I don't think this is an DateTime bug. I had the name problem with
Numeric arrays, when rich comparison's were introduced:
>>> from Numeric import *
>>> a = array((1,2,3))
>>> a == None
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: function not supported for these types, and can't coerce to
supported types
>>>
This worked just fine with older versions of Python.
a is None
works just fine, and I think is a cleaner way to code it anyway.
In general, the introduction of rich comparisons means that if __eq__ is
defined, special code would have to be written that handles the " ==
None" case. "is None" just makes more sense.
-Chris
--
Christopher Barker,
Ph.D.
ChrisHBarker at home.net --- --- ---
http://members.home.net/barkerlohmann ---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------
More information about the Python-list
mailing list