Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Default arguments in Python - the return - running out of ideas but...
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pascal Chambon  
View profile  
 More options May 13 2009, 5:09 pm
From: Pascal Chambon <chambon.pas...@wanadoo.fr>
Date: Wed, 13 May 2009 23:09:27 +0200
Local: Wed, May 13 2009 5:09 pm
Subject: Re: [Python-ideas] Default arguments in Python - the return - running out of ideas but...
Greg Falcon a écrit :
> Notice that

> def foo():
>     def myfunc(a, b, c = (yield [])):
>         pass

> already has a meaning in Python.  Under your proposal,

Aowh... I didn't even think this was legal, but indeed this works... so
it's obviously dead for "yield".

> Anyhow, since you've decided you want add a new kind of default
> argument spelled differently than the standard one, I have to ask what
> this buys you beyond

> def foo():
>     def myfunc(a, b, c = None):
>         if c is not None: # or a setinel
>             c = []

> Sure, it takes two more lines of code to write this (three if you want
> to use an object() instance as your sentinel to allow None being
> passed in), but does not require a new bit of language syntax for
> every Python programmer to learn...

> Greg F

Well, not only do we have to write more code, but we lose in
self-documentation I guess (I'd rather have the default appearing in the
signature than in the function code - pydoc and stuffs won't notice it),
and I find slightly disappointing the principle of a "sentinel", i.e "I
would have wanted to do something there but I can't so I'll do it
farther, take that in the meantime".

> There's the suggestion that Carl Johnson gave:

>     def myfunc(a, b, c else []):
>         pass

> or there's:

>     def myfunc(a, b, c def []):
>         pass

> where 'def' stands for 'default' (or "defaults to").

Those phrases could do it, I'm just worryied about the fact that
semantically, they make (to me) no difference with "c = []".
None of those ways looks more "dynamic" than teh other, so it might be
hard to explain why "=" means compiel time, and "def" means runtime.

I must admit I'm totally out of ideas then.

Regards,
Pascal

_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.