On 4/22/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > That (adding .format() in 2.6) occurred to me, but I dismissed it for some > reason. It can't have been a very good reason though, since I sure can't > remember what it was. > > In which case, Talin's PEP should probably suggest this as the implementation > strategy - python3warn and the instrumented python build can do their best to > pick up usage of % formatting, and we can add .format() to 2.6 so that forward > compatible code can be written in later 2.x releases. > > Now that I think about it, simply having python3warn pick up all uses of % in > a print statement should pick up many of the uses of string formatting. (Not > all, obviously, but a lot of them)
There's a different approach to discovering future incompatibilities than parsing the source code. I had originally forgotten about this approach even though I'd used the very thing myself years ago! It was pointed out to my by an audience member during my preview of my Python 3000 talk at the ACCU Silicon Valley chapter. I added a brief description to PEP 3000. The approach is to run your app (or a high-coverage test suite) with an instrumented Python 2.x interpreter which spits out warnings (or some other log) for run-time events that are known to break in Python 3.0. I did this years ago to find all instances of int/int in the standard library. It is trivial to do this for things like discovering string formatting. I believe it can also be used to discover cases where the result of dict.keys() etc. is used beyond iteration (we modify keys() to return a subclass of list that spits out a warning for all forms of access except __iter__()). This approach is complementary to the source code inspection approach; we should plan to use both in conjunction to get the maximally successful conversion (either automatic translation or at least automatic indication of issues to be changed). -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com