I just tried out trunk with a couple of my scripts. My html generator
(was using 0.5) works with 0.6/trunk without any code changes! Nice :-)
I had an old "generate a codepage chart" (like an ASCII chart but with
characters/bytes above 127 displayed) that didn't work but that was due
to the Unicode-support change I made a few releases back (rather than
version 0.6 related). I've attached a proposed patch (probably needs
some work as PrettyTable accepts kwargs rather than explicit regular
keyword arguments) that address this. This patch may also be the
building blocks of Python 3.0 compatibility (I don't use Python 3.x so
this is untested with 3.x). The patch basically preserves the Unicode
behavior but allows the caller to specify byte (or in Python 2.5 and
earlier, "str") semantics. Python 3.0 uses would need to call with str
so that 3.0 strings behavior works correctly.
Chris
I had an old "generate a codepage chart" (like an ASCII chart but with characters/bytes above 127 displayed) that didn't work but that was due to the Unicode-support change I made a few releases back (rather than version 0.6 related).Ah, I remember that application. Thanks for the patch. I'm a little busy at the moment with another project and with my thesis so I'm tossing up between putting of 0.6 a little longer and waiting until I have time to properly integrate your patch, or to declare that the unicode/str issue is sufficiently minor that we can just release 0.6 as it is now and save the patch for 0.7. This would be an easier decision to make if I was more knowledgeable about unicode in Python. Am I correct in thinking that applications where the current behaviour is a problem (like your ASCII chart) are unusual edge cases, and that most people would want PrettyTable to print "high bytes" as proper unicode characters if possible rather than whatever odd symbols you want in your ASCII chart?
This patch may also be the building blocks of Python 3.0 compatibility (I don't use Python 3.x so this is untested with 3.x).I have actually given some thought to 3.x compatibility and your patch is definitely a step in that direction. However, I don't think it's ever going to be possible to have the one version of PrettyTable work correctly on both 2.6.x and 3.x simply on account of the print --> print() change. Hopefully by the time 3.x is in widespread usage PrettyTable will be sufficiently complete and debugged that it won't be a big deal to simply run it through 2to3 and bump up the major release number and leave it at that.
I've been thinking about this and although it still feels kind of radical to do away with them, I've come to realise that the PrettyTable.printt() and PrettyTable.print_html() methods are in fact completely unecessary! Any call "x.printt(*args, **kwargs)" could be replaced by "print x.get_string(*args, **kwargs)" without any difference in result whatsoever. Eliminating the printing methods would (1) shorten the length of the module which is always a plus for maintenance, (2) solve any Python 3.x compatibility problems related to the print -> print() change (which would certainly be the biggest problem). If I included your patch and made this change the result would probably run just fine on 3.x.
This change would break a lot of existing code (I imagine), and since the idea has always been that 0.6 would be the release of big, breakey changes and after that the API would stabilise, it's more or less now or never for this idea. What do people think? If nobody has any compelling objections, I might do just this and put the result up as 0.6-RC2 for people to try out.
Luke