Tuesday, February 7, 2012

Re: about QuerySet

On Tuesday, 7 February 2012 11:36:04 UTC, newme wrote:
thank you.
then a basic python question.
how does queryset implement it?
does python also allow operator (e.g. []) overloading?


It's not usually called overloading in Python, but yes. Classes can define a `__getitem__` method which determines what to do when the square-bracket notation is used. You can see the code here:
https://code.djangoproject.com/browser/django/trunk/django/db/models/query.py#L165
--
DR. 

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

No comments:

Post a Comment