Python/Jython issues

Brett C. drifty at bigfoot.com
Thu Dec 19 04:22:39 EST 2002


vlprasad at yahoo.com (VLP) wrote in message news:<e8246d60.0212181742.6e5445a7 at posting.google.com>...

> strptime pure Python implementation from Python
> Cookbook cannot be imported in Jython. It uses a
> "property()" function that is unavailable to Jython
> looks like. 

Nope, Jython doesn't have ``property()``.  That is a CPython 2.2
feature and thus is not in Jython since it only supports CPython 2.1
code (I think).

>This same code works very well in Python.

Thanks!  Glad you think so!

> Anyone know where I can find a version of strptime
> that works with both? (or a way to get "property"
> working in Jython?)
> 

So here is the deal: ``property()`` is not critical for ``strptime()``
to work.  I put that in the code so as to make find out locale info
lazy.  You can rip out the ``property()`` assignments and just always
do the calculations in the ``__init__()`` method.  So, you could
change the line::

    f_weekday = property(__get_f_weekday, __set_nothing,
                        doc="Full weekday names")

to::

    f_weekday = self.__get_f_weekday()

in ``__init__()``; do this for all property values.  That is not the
best way to do the backport, but it will do the trick.

If you do decide to do a backport, make sure you grab the latest code
from CVS; all of my fixes have gone straight there and there have been
several fixes since the Cookbook came out.

If  you can muster some more people to clamor for this (just reply to
this post and make sure you cc: it to me), I would be willing to do
the backport to Jython myself and put it up on the Cookbook web site
as the current version of the recipe.

Hope that helps.

-Brett

P.S.: Thanks should go to Laura Creighton of AB Strakt of forwarding
this post to me.

P.P.S.: Thanks Laura for always being a supporter of my strptime
module.  First person to ever thank me for that recipe.  If I had
never heard from anyone I probably would not have bothered to put  as
much effort as I did into the darn thing after the first version.



More information about the Python-list mailing list