[python-uk] Library advice + anyone built a real time bidder?
Tim Golden
mail at timgolden.me.uk
Fri Mar 27 11:54:09 CET 2015
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
More information about the python-uk
mailing list