[python-uk] Library advice + anyone built a real time bidder?

Hansel Dunlop hansel at interpretthis.org
Fri Mar 27 12:03:58 CET 2015


Ah ha!

from the 2nd link:

# Python 2 and 3: option 1from six import reraise as raise_# orfrom
future.utils import raise_
traceback = sys.exc_info()[2]raise_(ValueError, "dodgy value", traceback)

Perfect, thanks Tim.

On Fri, Mar 27, 2015 at 10:54 AM, Tim Golden <mail at timgolden.me.uk> wrote:

> On 27/03/2015 10:47, Hansel Dunlop wrote:
> > Happy Friday Python People! (yes, you're happy, because it's Friday)
> >
> > Two questions for you:
> >
> > 1. I'm releasing a library. That I wrote in 2.7. But I want it to make it
> >     compatible with 2.7+. What's the best approach for this? Especially
> >     when a bit of code for 2.7 is a SyntaxError in 3+
> >
> >          raise test_exception, None, test_traceback   #   Syntax error
> in 3+
> >
> >          raise test_exception.with_traceback(test_traceback)  #   3+ api
> >
> >    So, do I write a convoluted bit of code that detects if I'm in 2.7 and
> >    wraps the exception in something that emulates the 3+ api?
> >    Do I have two similar modules, and decide which one to import based
> >    on Python version? Do I have two different versions?
> >    That seems like an obviously daft idea... but?
>
> (Hopefully) useful links:
>
> http://python3porting.com/noconv.html#handling-exceptions
>
> http://python-future.org/compatible_idioms.html
>
> https://docs.python.org/3/howto/pyporting.html#update-your-code
>
> I'm not sure if they exactly address your case, but hopefully they'll
> take you in the right direction.
>
> TJG
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> https://mail.python.org/mailman/listinfo/python-uk
>



-- 

                                Hansel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-uk/attachments/20150327/9288131a/attachment.html>


More information about the python-uk mailing list