[Python-ideas] parameter omit

Aaron Brady castironpi at comcast.net
Fri May 11 09:16:46 CEST 2007


> -----Original Message-----
> From: Steven Bethard [mailto:steven.bethard at gmail.com]
> Sent: Friday, May 11, 2007 2:11 AM
> 
> On 5/11/07, Aaron Brady <castironpi at comcast.net> wrote:
> > > -----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:
> > > > [snip]
> > >
> > > 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.
> 
> If you really care about lines and characters, you can write::
> 
>     k = {}
>     if self.filename: k['filename'] = self.filename
>     if hasattr(self, 'hook'): k['reporthook'] = self.hook
>     urlretrieve(self.url, **k)
> 
> That's 4 lines, 132 characters, compared to your 3 lines, 133 characters.
> 
> But the fact that you're drawing the "lets count lines of code" card
> suggests that there's no point discussing this any further.
> 
> Good luck with your proposal.
> 
> STeVe

Fine.  No dice on lines of code alone.  We talk readability.  Tell me yours
is easier to read, compressed or no.






More information about the Python-ideas mailing list