On Jul 2, 2011, at 10:52 AM, cjrh wrote:
>  The point regarding backwards compatibility is well-taken, I wouldn't want 
> to mess with that at all.  However, cognitive dissonance in code is a 
> particular bugbear of mine.  I am especially nervous (in general) of 
> situations where one thing is used to *sematically* represent a different 
> kind of thing.  "=None" and "=False" behaving differently in this case makes 
> me uncomfortable.  Imagine that the argument was called something like 
> "extension_override" and then you should be able to see my concern more 
> clearly.   Still, it isn't a big deal.  I can live with the current 
> behaviour.  As JL says, "=None" is almost idiomatic in Python to represent 
> "default" behaviour, not necessarily the value "None".  Perhaps my gripe is 
> with the idiom rather than web2py specifically.

Perhaps so, and in part with Python's choice of 'None' as the name of the nil 
singleton; it carries more semantic baggage than 'Nil' or 'Null' would have 
done.

And elaborating a little on the default-argument convention, None is the 
conventional default when a dynamic default is required, as it is in this case. 
If the default really were 'html', then it could be so specified. But since the 
default is request.extension (and only 'html' if *that* isn't defined), we use 
None. (Argument defaults are fixed when the function is defined, so you can't 
say something like extension=r.extension.)

Yet another approach would be to have yet another singleton object to be used 
for dynamic default arguments (called, perhaps, Default), but the use of None 
for that purpose is pretty deeply embedded in Python practice, and changing it 
would be confusing.

Reply via email to