PEP 3102 for review and comment

Discussion in 'Python' started by molasses, May 24, 2006.

  1. molasses

    molasses Guest

    I don't mind the naked star and will be happy if thats what we end up with.

    Though how about using *None?
    I think that makes the intention of the function clearer.

    eg.
    def compare(a, b, *None, key=None):

    Which to me reads as "no further positional arguments".

    Or alternatively:
    def compare(a, b, *0, key=None):

    -- Mark
     
    molasses, May 24, 2006
    #1
    1. Advertising

  2. molasses

    gangesmaster Guest

    None is not currently a keyword
     
    gangesmaster, May 24, 2006
    #2
    1. Advertising

  3. molasses

    Kay Schluehr Guest

    molasses wrote:
    > I don't mind the naked star and will be happy if thats what we end up with.
    >
    > Though how about using *None?
    > I think that makes the intention of the function clearer.
    >
    > eg.
    > def compare(a, b, *None, key=None):
    >
    > Which to me reads as "no further positional arguments".
    >
    > Or alternatively:
    > def compare(a, b, *0, key=None):
    >
    > -- Mark


    Argh!

    Sorry, but this syntax seems to me a perlish hackaround. Although the
    star is clearly beautifull and veeeery pythonic ;)

    >From the PEP:

    One can easily envision a function
    which takes a variable number of arguments, but also takes one
    or more 'options' in the form of keyword arguments. Currently,
    the only way to do this is to define both a varargs argument,
    and a 'keywords' argument (**kwargs), and then manually extract
    the desired keywords from the dictionary.

    The current solution is fine and not very troublesome. But if you want
    to drop a named dict just replace it by an unnamed one ( unless you
    think this will seduce people to use devilish, horrible lambda ... ).

    Suggestions:

    def compare(a, b, *args, **kwd): # the classics

    def compare(a, b, *args, {"key":None}): # pass keywords in unnamed
    dict

    def compare(a, b, *args, {key=None}): # alternative syntax

    def compare(a, b, *args, **kwd={...,"key":None}): # having the
    cake and eating it

    Regards,
    Kay
     
    Kay Schluehr, May 24, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alec S.
    Replies:
    10
    Views:
    10,265
    Alec S.
    Apr 16, 2005
  2. Guido van Rossum
    Replies:
    21
    Views:
    630
    Steven Bethard
    Jun 6, 2005
  3. Talin
    Replies:
    3
    Views:
    340
    Talin
    May 22, 2006
  4. Tony Lownds
    Replies:
    4
    Views:
    475
    Tony Lownds
    Jan 1, 2007
  5. =?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=

    Re: PEP 3107 Function Annotations for review and comment

    =?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=, Dec 30, 2006, in forum: Python
    Replies:
    9
    Views:
    376
    Tony Lownds
    Jan 1, 2007
Loading...

Share This Page