From: David Alan Black Date: 2002-08-08T07:57:10+09:00 Subject: RE: Named paramters again Hi -- On Thu, 8 Aug 2002, Rich Kilmer wrote: > Named parameters can also be used to allow for methods where default > values are supplied for specific parameters: > > def foo(x, y=2, z=3) > ... > end > > If you want to call this and set 'z' but leave 'y' is default value, > named parameters are your friend. > > foo(2, z: 4) > > Where this is used a lot in python are constructors in GUI widgets were > lots > of default values can be set and you only need to provide those you wish > to > 'override'...and yes...order independence becomes relevant here too > because you will have a hard time maintaining the order in your head for > 20 or 30 parameters. Granted, you could just implement this as > subsequent calls to attribute getter/setters, but it's nice to be able > to do it in widget construction. I'm completely GUI-programming ignorance, but I'll accept on faith that the interface authors have good reason to do it this way (rather than wrapping the arguments up in an object). But I'm still not sure this should be taken as a model for language-level change. Isn't it sort of good that the language doesn't make 20-parameter methods convenient? :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav