Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'read.': 0.03; 'interpreter': 0.05; 'widely': 0.05; 'debug': 0.07; 'debugging': 0.07; 'python3': 0.07; 'skip:" 60': 0.07; 'subject:Error': 0.07; 'string': 0.09; 'false,': 0.09; 'type,': 0.09; 'types:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '00:00:00': 0.16; '24,': 0.16; 'apology': 0.16; 'cc:name:python list': 0.16; 'differs': 0.16; 'fabio': 0.16; 'googling': 0.16; 'hint?': 0.16; 'object).': 0.16; 'other,': 0.16; 'there...': 0.16; 'typeerror:': 0.16; 'url:py': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'module': 0.19; '<': 0.19; 'seems': 0.21; 'feb': 0.22; '>>>': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'topic': 0.29; 'url:code': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; '"",': 0.31; 'file:': 0.31; 'skip:& 70': 0.31; 'file': 0.32; 'probably': 0.32; 'thanks!': 0.32; 'run': 0.32; 'linux': 0.33; 'url:python': 0.33; '(most': 0.33; 'url:source': 0.33; 'subject:the': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'instances': 0.36; 'url:listinfo': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'two': 0.37; 'step': 0.37; 'skip:& 10': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'sure': 0.39; 'url:mail': 0.40; 'forum': 0.61; 'skip:n 10': 0.64; 'url:p': 0.64; 'more': 0.64; 'different': 0.65; 'to:addr:gmail.com': 0.65; 'integrated': 0.69; "'appears'": 0.84; '2014,': 0.84; 'skip:/ 30': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=+HB7+0Jb5pBGPtuQqr892chNv5FpwYTfrsxQYIGm5J4=; b=Ystqy22CpCcQBjrbcrzrrf0OLybkF7hlfXVqhGUT0Ffih0TqRXhjkhnK+XdheGjgAC NpTj3gNXYVhbVn1smn0rGDgHSoB0I2YDFY/b4BYvCsdCfSd5zuKdzvXU9jdTM1sFvcy/ 1/G9a7hBYgmi3X199UiG8bVbb23C5MDVYaAREJhaYjD5V2ZHhA5chhUqU1vhw9yDHZD1 DFgmpzfv6IG5hPTsSd3ciCyGgUBtpEt1cJ9oahVjqyRopf+wMRX/zUyKAgyiqJ26mAN/ PrC5f3U9D3N26M0j+/71Sd1J+4WHrHEeJrq+sOgt49mDdz7x3l3+ToXYO9BYZ1XczbZA TL9w== X-Received: by 10.220.160.67 with SMTP id m3mr527347vcx.56.1403617632037; Tue, 24 Jun 2014 06:47:12 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Fabio Zadrozny Date: Tue, 24 Jun 2014 10:46:51 -0300 Subject: Re: Error in PyDev but not in the standard python interpreter To: Fabien Content-Type: multipart/alternative; boundary=001a11c2a89e5bb25c04fc953276 Cc: python list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 173 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1403619503 news.xs4all.nl 2876 [2001:888:2000:d::a6]:44940 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73549 --001a11c2a89e5bb25c04fc953276 Content-Type: text/plain; charset=UTF-8 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 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@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 "", line 1, in > 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 > --001a11c2a89e5bb25c04fc953276 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
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=3D1117 and it has a 'datetime' whi= ch says: "Phony datetime object which mimics the python datetime objec= t", 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 an= d do a debug run to step into the 'num2date' call to see what diffe= rs there... (i.e.: I think that if you do isinstance(d1, datetime) it'l= l 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@gmail.com&g= t; 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@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 =3D num2date(0, 'days since 1000-01-01', 'stand= ard')
>>> d2 =3D datetime(2000, 1, 1)
>>> print(d1 < d2)
True

But if I run the code in PyDev I get:
=C2=A0 =C2=A0 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: =C2=A0 =C2=A0 =C2=A0 datetime
String Form:1000-01-01 00:00:00
File: =C2=A0 =C2=A0 =C2=A0 /usr/local/lib/python3.3/dist-packages/ne= tcdftime.py
Docstring:
[...]
>>> ?d2
Type: =C2=A0 =C2=A0 =C2=A0 datetime
String Form:2000-01-01 00:00:00
File: =C2=A0 =C2=A0 =C2=A0 /usr/lib/python3.3/datetime.py
Docstring:
[...]
>>> d1 < d2
Traceback (most recent call last):
=C2=A0 File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2732, in run_code
=C2=A0 =C2=A0 exec(code_obj, self.user_global_ns, self.user_ns)
=C2=A0 File "<ipython-input-29-415dec1be9aa>", line = 1, in <module>
=C2=A0 =C2=A0 d1 < d2
TypeError: unorderable types: datetime() < datetime.datetime()


So they are two instances of the same object but something in pyDev doesn&#= 39;t want to compare them. Any Hint?

Thanks!

Fabien



--
https://mail.python.org/mailman/listinfo/python-list

--001a11c2a89e5bb25c04fc953276--