How to do *args, **kwargs properly

Lasse Vågsæther Karlsen lasse at vkarlsen.no
Tue Oct 11 08:58:04 EDT 2005


George Sakkis wrote:
> "Lasse Vågsæther Karlsen" <lasse at vkarlsen.no> wrote:
<snip>
>>I think I'll re-write to use a list instead
> 
> 
> Actually in most cases you don't need to assume it's a list; any
> iterable is usually good enough. You can always turn it into a list (or
> a tuple or a set or..) in the function if you really have to. So when
> you do have to and when you don't ? You don't have to if all you do is
> iterate over the elements. This is true even if you want to iterate
> more than once; just use the itertools.tee() function to create N
> independent iterators. To sum up, a better signature for your function
> is likely to be "def fn(iterable, cmp=cmp)".

Yep, that sounds like a plan :)

-- 
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:lasse at vkarlsen.no
PGP KeyID: 0x2A42A1C2



More information about the Python-list mailing list