[Python-ideas] parameter omit
Aaron Brady
castironpi at comcast.net
Fri May 11 08:57:43 CEST 2007
> -----Original Message-----
> From: Steven Bethard [mailto:steven.bethard at gmail.com]
> Sent: Friday, May 11, 2007 1:50 AM
>
> On 5/11/07, Aaron Brady <castironpi at comcast.net> wrote:
> > Take a shot at this one.
> >
> > class WebRetrieveElement:
> > def netretrieveOld( self ):
> > if hasattr( self,'hook' ) and self.filename:
> > urlretrieve( self.url, self.filename, self.hook
> )
> > elif hashook:
> > urlretrieve( self.url, reporthook= self.hook )
> > else:
> > urlretrieve( self.url, self.filename )
>
> def netretrieve(self):
> kwargs = {}
> if self.filename:
> kwargs['filename'] = self.filename
> if hasattr(self, 'hook'):
> kwargs['reporthook'] = self.hook
> urlretrieve(self.url, **kwargs)
Right. That's the alternative, -as- I keep bringing up.
Now let's compare, and judge if X is worth Y.
My solution, 3 lines. Yours, 6.
X = 50% profit, -plus- the attention you save. Y = a built-in, unobtrusive
variable, a trivial cost. `None' doesn't get in your way, does it?
As you can see, X -is- worth Y. Therefore, my proposal is better.
More information about the Python-ideas
mailing list