Python + IIS/ASP questions (modules, namespaces, etc)

sismex01 at hebmex.com sismex01 at hebmex.com
Fri Dec 20 13:52:25 EST 2002


> From: pibble at yahoo.com [mailto:pibble at yahoo.com]
> Sent: Friday, December 20, 2002 11:31 AM
> 
> sismex01 at hebmex.com wrote in message 
> news:<mailman.1040337986.15815.python-list at python.org>...
> 
> > Use zip to reorder your row/column data, to convert it
> > into a list of tuples [ (row1), (row2), ... ]:
> > 
> >     zip(*ado.getrows()) -> list
> > 
> > It's fairly quick.
> > 
> > -gustavo
> 
> 
> Ah, beautiful.  I knew that builtin function would come in handy
> someday.
> 
> I'm not sure about your syntax.  I used this:
> 
> column_major_list = ado.GetRows()
> row_major_list = apply(zip, column_major_list)
> [...snip...]

It's the same thing, only for Python 2.2.

In earlier versions of python, if you needed to
specify an arbitrary amount of positional arguments,
or keyword arguments, you needed 'apply' to do the
function call:

    apply(function, (pos-args-tuple), {kw-args-dict})

But, in recent versions of python, you can ommit apply
and simply specify a tuple (or list) to use as "the rest
of the positional args", and a dictionary to use as
"these other keyword args", with this syntax:

   function(*pos_args_tuple, **kw_args_dict)

So, when I write:

   zip(*ado.getrows())

Actually, this is equivalent to:

   apply(zip, tuple(ado.getrows()), None)

HTH

-gustavo




More information about the Python-list mailing list