[Python-3000] PEP 3113 (Removal of Tuple Parameter Unpacking)

Collin Winter collinw at gmail.com
Sat Mar 3 05:25:07 CET 2007


On 3/2/07, Guido van Rossum <guido at python.org> wrote:
> On 3/2/07, Collin Winter <collinw at gmail.com> wrote:
> > On 3/2/07, Guido van Rossum <guido at python.org> wrote:
> > > Has anyone tried to create a 2to3 transformer for this? I think it
> > > should be possible, although there are a few warts (like inserting the
> > > new code after the docstring, and how to come up with names for the
> > > anonymous tuple(s), and having to do it for potentially any number of
> > > arguments. Still, it would require no dataflow analysis, and the
> > > except transformer already has a similar statement insertion. So I
> > > think it's doable.
> >
> > I can take a crack at this. I had to do similar things for the raise
> > fixer before switching it over to use with_traceback().
>
> That would be great! You may end up adding some generally useful code
> for inserting statements into a block...

I just checked in fixes/fix_tuple_params.py (and associated tests). I
still want to work on the code that generates the new names (so that
they'll be more appropriate), but the functionality is there.

I definitely want to sit down and abstract out the "insert these stmts
at the beginning of a suite" logic. fix_tuple_params includes support
for "def foo(): x = 5; y = 7"-style functions, which leads to some
less-than-attractive code.

Collin Winter


More information about the Python-3000 mailing list