Development

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • **kwargs?

    2 answers - 630 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Francois De Serres wrote:
    All your **kwargs are belong to us.
    *args is documented in the Tutorial. I reckon **kwargs represents a
    dictionary of arguments. But I don't quite get the semantics of **x.
    Undefined length tuple of undefined length tuples? Are there other
    practical use cases for ** (common enough please, I wish I was, but I'm
    not a scientist).
    Where did you get "tuples of tuples" for **x ? It doesn't have tuples
    at all, but is merely a dictionary, as you said in the first place. Are
    you implying you think **kwargs and **x are somehow magically different?
    -Peter
  • No.1 | | 995 bytes | |

    Peter Hansen wrote:
    Francois De Serres wrote:


    >*args is documented in the Tutorial. I reckon **kwargs represents a
    >dictionary of arguments. But I don't quite get the semantics of **x.
    >Undefined length tuple of undefined length tuples? Are there other
    >practical use cases for ** (common enough please, I wish I was, but
    >I'm not a scientist).


    Where did you get "tuples of tuples" for **x ?

    I would guess it is confusion from languages where unary * means
    dereference and ** means double dereference.

    To the P: I'm glad you have been reading the tutorial. If you have
    further questions the reference manual is a good place to look:

    Just as you can use a name other than self as the first argument to an
    unbound method, you can call your *args and **kwargs *x and **y instead,
    but they will still act just like *args and **kwargs.

    The stars are magic, not the names.
  • No.2 | | 1548 bytes | |

    Michael Hoffman wrote:

    >Peter Hansen wrote:


    >
    >>Francois De Serres wrote:
    >>

    >
    >>

    >


    args is documented in the Tutorial. I reckon **kwargs represents a
    dictionary of arguments. But I don't quite get the semantics of **x.
    Undefined length tuple of undefined length tuples? Are there other
    practical use cases for ** (common enough please, I wish I was, but
    I'm not a scientist).


    >>Where did you get "tuples of tuples" for **x ?

    >
    >>

    >
    >I would guess it is confusion from languages where unary * means
    >dereference and ** means double dereference.


    That was precisely my mistake.

    >To the P: I'm glad you have been reading the tutorial. If you have
    >further questions the reference manual is a good place to look:
    >
    >


    Now I see, there's a '**' token, which is not the same as two adjacents
    '*' tokens.

    >Just as you can use a name other than self as the first argument to an
    >unbound method, you can call your *args and **kwargs *x and **y instead,
    >but they will still act just like *args and **kwargs.
    >
    >The stars are magic, not the names.


    Thanks mucho!
    F.

Re: **kwargs?


max 4000 letters.
Your nickname that display:
In order to stop the spam: 9 + 8 =
QUESTION ON "Development"

EMSDN.COM