Re: Python 3 - style question

2012-08-11 Thread Aymeric Augustin
On 11 août 2012, at 11:00, Aymeric Augustin wrote: > Thanks for all your answers. A decorator will indeed be the cleanest solution. Given the large number of existing __unicode__ methods (66 in django, 375 in the tests) I've written a custom 2to3 fixer to perform the transformation.

Re: Python 3 - style question

2012-08-10 Thread Alex Gaynor
On Fri, Aug 10, 2012 at 3:45 PM, Simon Meers wrote: > > On 10 August 2012 18:56, Vinay Sajip wrote: > >> I think Option 2 is better, for the reasons you state. > > +1. And it's not too entangled to be easily stripped out if/when > Python 2 support is

Re: Python 3 - style question

2012-08-10 Thread Simon Meers
> On 10 August 2012 18:56, Vinay Sajip wrote: >> I think Option 2 is better, for the reasons you state. +1. And it's not too entangled to be easily stripped out if/when Python 2 support is removed. On 11 August 2012 06:10, Łukasz Rekucki wrote: >

Re: Python 3 - style question

2012-08-10 Thread Łukasz Rekucki
On 10 August 2012 18:56, Vinay Sajip wrote: > I think Option 2 is better, for the reasons you state. > How about wrapping those 3 lines of code into a class decorator (preferably named more explicit then StrAndUnicode) ? That would be at least a little DRY. -- Łukasz

Re: Python 3 - style question

2012-08-10 Thread claudep
Le vendredi 10 août 2012 05:28:42 UTC+2, Daniel Sokolowski a écrit : > > I prefer Proposal 2 out of the list, and regarding Russell's point I > believe that the tutorial ought to promote Python 3 and be written from > that perspective with Python 2 exceptions - because exactly of Django's >

Re: Python 3 - style question

2012-08-09 Thread Daniel Sokolowski
I prefer Proposal 2 out of the list, and regarding Russell's point I believe that the tutorial ought to promote Python 3 and be written from that perspective with Python 2 exceptions - because exactly of Django's importance in the Python landscape. Thanks and good day. On 09/08/2012 19:35,

Re: Python 3 - style question

2012-08-09 Thread Russell Keith-Magee
On Fri, Aug 10, 2012 at 4:58 AM, charettes wrote: > I think this will only be an issue for django application maintainers. > > IMHO, projects target a specific version of python and won't have to provide > python 2-3 compatibility. Am I wrong? Yes and no. On the one hand

Re: Python 3 - style question

2012-08-09 Thread charettes
I think this will only be an issue for django application maintainers. IMHO, projects target a specific version of python and won't have to provide python 2-3 compatibility. Am I wrong? Le jeudi 9 août 2012 16:36:12 UTC-4, Aymeric Augustin a écrit : > > Hello, > > One of the first lessons in

Python 3 - style question

2012-08-09 Thread Aymeric Augustin
Hello, One of the first lessons in the tutorial is to define a __unicode__ method. In Python 3, __unicode__ is replaced by __str__ (and __str__ by __bytes__, but that method won't be needed in general). Writing these methods in a way works on both Python 2 and 3 proves surprisingly messy. I'd