On Mar 4, 2010, at 7:37 PM, Phlip wrote:
> 
> Sorry, I didn't say "operator overload" (which are either spot-on or
> sophomoric, when they work).

I'm using "operator overloading" in this case because "id=" already has a 
specific function, and you would have it do something in addition to that 
function.  I may be using the term incorrectly.

> Because, IIRC, no SQL database can store arrays ('list's) in fields,
> the =[] event is free to be "overloaded" by its type.

Entertainingly, Postgresql does have array types 
(http://www.postgresql.org/docs/8.4/interactive/arrays.html), though that's 
more of an exception than the general case.  Django's ORM doesn't support db 
arrays directly, though there is the CommaSeparatedIntegerField, which 
approximates a primitive version.

> So id=[] would resolve to id__in=[], id=Scalar to id__exact=Scalar,
> and the explicit versions are available if you suspect that
> overloading is fragile.

Interesting thought.  Might be worth doing, to see how practical it is.  You 
should start it as a third-party project, see how much traction it gets.
> 
> (I also disagree with leaving out the spaces around =, but obviously
> obeying a team style guide supersedes improving it...)

Interestingly, that particular style choice is part of the language-level style 
guide, PEP8 (http://www.python.org/dev/peps/pep-0008/), rather than 
Django-specific.  Needless to say, it's a guide, rather than a syntax error, so 
it could be (and occasionally is, in some projects) ignored at the project 
level.  In the case of Django, though, PEP8 is specified.  I personally think 
it's a good thing that there's a language-level style guide, which is entirely 
consistent with both the goal of clarity/legibility, and the philosophy that 
"there should be one --and preferably only one-- obvious way to do it".  It 
means I don't have to think about style, I can instead focus on solving the 
problem.  Which is, really, the entire point of any style guide.

---Peter

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to