Default paranmeter for packed values

Xavier Ho contact at xavierho.com
Mon Apr 19 02:14:43 CEST 2010


On Mon, Apr 19, 2010 at 9:46 AM, Chris Rebert <clp2 at rebertia.com> wrote:

> It doesn't really make sense to use * in such situations anyway, you
> can just do the normal `z = (1,2,3)`


But calling function(1.0, (0.0, 1.0, 0.0)) has been a big pet peeve of mine,
and it looks extremely ugly and, imo, unpythonic.

On Mon, Apr 19, 2010 at 9:54 AM, Stephen Hansen <apt.shansen at gmail.com>wrote:
def t(a, *b):
    if not b:
        b = (2,3)
    ...

Brilliant! I can live with that. =D
def t(a, *b):
    if not b:
        b = (2, 4)
    print a, b

t(1)
1 (2, 4)
t(1, 3, 4)
1 (3, 4)
t(1, 3, 4, 5)
1 (3, 4, 5)

Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100419/b6b73587/attachment.html>


More information about the Python-list mailing list