Error in PyDev but not in the standard python interpreter

Fabio Zadrozny fabiofz at gmail.com
Tue Jun 24 09:46:51 EDT 2014


Well, it 'appears' to be the same type, but given that the File from one is
different from the other, I think they aren't...

Googling a bit, I found the source:
https://code.google.com/p/netcdf4-python/source/browse/trunk/netcdftime.py?r=1117
and it has a 'datetime' which says: "Phony datetime object which mimics the
python datetime object", now, I'm not sure why it works in the Python shell
but not in the IPython shell integrated in PyDev... You may want to create
a module and do a debug run to step into the 'num2date' call to see what
differs there... (i.e.: I think that if you do isinstance(d1, datetime)
it'll return false, as it seems to be a netcdftime.datetime object).

Best Regards,

Fabio


On Tue, Jun 24, 2014 at 10:28 AM, Fabien <fabien.maussion at gmail.com> wrote:

> Hi,
>
> this is probably not the best place for this topic but I know this forum
> is widely read. I take this opportunity and apology at the same time.
>
> If I run this in my python3 interpreter everything works fine:
>
> mowglie at flappi ~ $ python3
> Python 3.3.2+ (default, Feb 28 2014, 00:52:16)
> [GCC 4.8.1] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from netCDF4 import num2date
> >>> from datetime import datetime
> >>> d1 = num2date(0, 'days since 1000-01-01', 'standard')
> >>> d2 = datetime(2000, 1, 1)
> >>> print(d1 < d2)
> True
>
> But if I run the code in PyDev I get:
>     print(d1 < d2)
> TypeError: unorderable types: datetime() < datetime.datetime()
>
> When debugging in pyDev, everything looks fine:
> >>> sys.version
> Out[28]: '3.3.2+ (default, Feb 28 2014, 00:52:16) \n[GCC 4.8.1]'
> >>> ?d1
> Type:       datetime
> String Form:1000-01-01 00:00:00
> File:       /usr/local/lib/python3.3/dist-packages/netcdftime.py
> Docstring:
> [...]
> >>> ?d2
> Type:       datetime
> String Form:2000-01-01 00:00:00
> File:       /usr/lib/python3.3/datetime.py
> Docstring:
> [...]
> >>> d1 < d2
> Traceback (most recent call last):
>   File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py",
> line 2732, in run_code
>     exec(code_obj, self.user_global_ns, self.user_ns)
>   File "<ipython-input-29-415dec1be9aa>", line 1, in <module>
>     d1 < d2
> TypeError: unorderable types: datetime() < datetime.datetime()
>
>
> So they are two instances of the same object but something in pyDev
> doesn't want to compare them. Any Hint?
>
> Thanks!
>
> Fabien
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140624/bc9e57b7/attachment.html>


More information about the Python-list mailing list