Parameterized functions of no arguments?

Ben Finney ben+python at benfinney.id.au
Fri Feb 11 09:55:59 CET 2011


Rotwang <sg552 at hotmail.co.uk> writes:

> On 11/02/2011 05:42, Ben Finney wrote:
> > What part is inelegant to your eye?
>
> I guess the fact that it exploits the way Python evaluates default
> function arguments to achieve something other than what they were
> intended for.

I see. If that seems like an exploit, I can see why you think it's
inelegant.

> Still, I see that Chris suggested the same solution (thanks, Chris) so
> it clearly isn't something that's frowned upon.

Indeed, in this forum we go to tedious lengths to explain that this
behaviour is the case in Python, so code that depends on it may even be
encouraged :-)

-- 
 \      “He that loveth father or mother more than me is not worthy of |
  `\        me: and he that loveth son or daughter more than me is not |
_o__)                worthy of me.” —Jesus, as quoted in Matthew 10:37 |
Ben Finney



More information about the Python-list mailing list