Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73546

Re: Error in PyDev but not in the standard python interpreter

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; '"""': 0.07; 'class,': 0.07; 'subject:Error': 0.07; '[1]:': 0.09; 'check,': 0.09; 'falls': 0.09; 'objects,': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; '24,': 0.16; '__lt__': 0.16; 'calendar.': 0.16; 'docstring': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hint?': 0.16; 'itself,': 0.16; 'luck!': 0.16; 'url:py': 0.16; 'subject:python': 0.16; 'weird': 0.16; 'wrote:': 0.18; 'module': 0.19; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; '(such': 0.24; '(or': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'compare': 0.26; 'define': 0.26; 'header:In-Reply-To:1': 0.27; '[1]': 0.29; 'url:code': 0.29; "doesn't": 0.30; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; 'comparison': 0.31; 'skip:c 30': 0.32; '(i.e.': 0.33; 'url:source': 0.33; 'actual': 0.34; 'subject:the': 0.34; 'info': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'dates': 0.36; 'instances': 0.36; 'should': 0.36; 'two': 0.37; 'handle': 0.38; 'pm,': 0.38; 'that,': 0.38; 'does': 0.39; 'itself': 0.39; 'either': 0.39; "you're": 0.61; 'real': 0.63; 'skip:n 10': 0.64; 'url:p': 0.64; 'world': 0.66; 'calendars': 0.84; 'skip:/ 30': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=bGxuVrAyI3fq2Kl+JSNYJeShFcA4fj4Ns+e2QpE5lpM=; b=mswdmXBuw4j0zIkIf0ok0iXM8N4em8bZZzLKdMlUz5uJA9/TDltOZHzyZP9iHNQuJk 9vpsnGFiM/j2j/eNtFpQ8V0QPzqzDQgoLdV/kMQ8Tjls5tyq9N49dIVSmP9czftH3ZvF 9GxPd2ZINMHCHW7M94a6q1I7uE85Orv0KVyC2xy3euaSpnTnmCHbTuxecJaIJGQYvJG+ IGm4mSLkRks31042NyTrW+LlpyDEkkxqjU2hZRsu37Ru13Nu90xJxHVdZ3zB63tKCGTS f/T3Ff0oykHMfeD2K/5IozwYoxxu8LYeRu1GWQRWzkxBvVDM8KJlKbtKrLikvQWjeWiD qo9Q==
MIME-Version 1.0
X-Received by 10.53.12.229 with SMTP id et5mr707223vdd.32.1403617670905; Tue, 24 Jun 2014 06:47:50 -0700 (PDT)
In-Reply-To <lobued$r48$1@speranza.aioe.org>
References <lobued$r48$1@speranza.aioe.org>
Date Tue, 24 Jun 2014 23:47:50 +1000
Subject Re: Error in PyDev but not in the standard python interpreter
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11218.1403617680.18130.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1403617680 news.xs4all.nl 2919 [2001:888:2000:d::a6]:34715
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73546

Show key headers only | View raw


On Tue, Jun 24, 2014 at 11:28 PM, Fabien <fabien.maussion@gmail.com> wrote:
> So they are two instances of the same object but something in pyDev doesn't
> want to compare them. Any Hint?

Are they really instances of the same class? One of them comes from
/usr/local/lib/python3.3/dist-packages/netcdftime.py and the other
comes from /usr/lib/python3.3/datetime.py - so they might be virtually
identical (or they might not), but they're not the actual same class,
and when __lt__ does its isinstance check, it doesn't pass.

The real question is: Why is netCDF4 not using "import datetime" to
get its datetime? And I think that's best answered with this, lifted
from the netcdftime.utime docstring [1]:

"""
The datetime instances returned by C{num2date} are 'real' python datetime
objects if the date falls in the Gregorian calendar (i.e.
C{calendar='proleptic_gregorian', 'standard'} or C{'gregorian'} and
the date is after 1582-10-15). Otherwise, they are 'phony' datetime
objects which are actually instances of C{L{netcdftime.datetime}}.  This is
because the python datetime module cannot handle the weird dates in some
calendars (such as C{'360_day'} and C{'all_leap'}) which don't exist in any real
world calendar.
"""

(Similar info can be found in the docstring for netcdftime.datetime
itself, but without the examples.)

ISTM netcdftime.datetime should define __lt__() to permit comparisons
with either others of itself or datetime.datetime objects, but in the
absence of that, you're stuck with either ensuring that you're working
with Gregorian dates, or writing your own comparison function.

Good luck!

ChrisA

[1] https://code.google.com/p/netcdf4-python/source/browse/trunk/netcdftime.py?r=1117#522

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Error in PyDev but not in the standard python interpreter Fabien <fabien.maussion@gmail.com> - 2014-06-24 15:28 +0200
  Re: Error in PyDev but not in the standard python interpreter Chris Angelico <rosuav@gmail.com> - 2014-06-24 23:47 +1000
    Re: Error in PyDev but not in the standard python interpreter Fabien <fabien.maussion@gmail.com> - 2014-06-24 15:59 +0200
      Re: Error in PyDev but not in the standard python interpreter Chris Angelico <rosuav@gmail.com> - 2014-06-25 00:04 +1000
        Re: Error in PyDev but not in the standard python interpreter Fabien <fabien.maussion@gmail.com> - 2014-06-24 16:27 +0200
          Re: Error in PyDev but not in the standard python interpreter Chris Angelico <rosuav@gmail.com> - 2014-06-25 00:35 +1000
            Re: Error in PyDev but not in the standard python interpreter Fabien <fabien.maussion@gmail.com> - 2014-06-24 17:40 +0200
              Re: Error in PyDev but not in the standard python interpreter Chris Angelico <rosuav@gmail.com> - 2014-06-25 01:58 +1000
              Re: Error in PyDev but not in the standard python interpreter Ethan Furman <ethan@stoneleaf.us> - 2014-06-24 09:02 -0700
      Re: Error in PyDev but not in the standard python interpreter Ethan Furman <ethan@stoneleaf.us> - 2014-06-24 08:08 -0700
  Re: Error in PyDev but not in the standard python interpreter Fabio Zadrozny <fabiofz@gmail.com> - 2014-06-24 10:46 -0300
  Re: Error in PyDev but not in the standard python interpreter Tony the Tiger <tony@tiger.invalid> - 2014-06-28 20:39 +0000

csiph-web