[Python-ideas] parameter omit

Aaron Brady castironpi at comcast.net
Fri May 11 07:51:32 CEST 2007


> -----Original Message-----
> From: Talin [mailto:talin at acm.org]
> Sent: Friday, May 11, 2007 12:39 AM
> 
> Aaron Brady wrote:
> >> -----Original Message-----
> >> From: Josiah Carlson [mailto:jcarlson at uci.edu]
> >> Sent: Thursday, May 10, 2007 8:04 PM
> >>
> >> "Aaron Brady" <castironpi at comcast.net> wrote:
> >> [snip]
> > I don't like it.  Cobol is sufficient.  Python is very cool.
> >
> >>     def foo(arg1, **kwargs):
> >>         arg2 = kwargs.get('arg2', 1.2325)
> >>         arg3 = kwargs.get('arg3', 'hello')
> >>         ...
> >
> > Library functions have many parameters, and huge if statements are hard
> to
> > read.  My solution costs only a single built-in object, not even a
> keyword
> > or syntax modification.  Your solution takes a three-line function
> > definition.  Compare to mine:
> >
> >      def foo(arg1, argFoo=1.2325, argBree='hello'):
> >          ...
> >
> > Specific and concise.  Clearly better, by all measures I read.
> 
> With PEP 3102 in place you don't even need the **kwargs:
> 
> http://www.python.org/dev/peps/pep-3102/
> 
> -- Talin

I'm not adding restrictions.  I'm simplifying.  The subject solution is
general.  Less code in all cases, meaning still as clear or clearer.





More information about the Python-ideas mailing list