I recently was introduced to the concept of descriptors in Python, and it
looks like fields like CharField() are descriptors. However, I find the
concept of descriptors quite enigmatic, and am trying to piece together the
puzzle bu asking related questions.

For now my question is: What do we gain by having these attributes on the
class rather than on the instance? I mean, why can't the fields we are
using in a model be defined in __init__()?

I know it's common practice to instantiate descriptors on a class-level,
but I don't know why. I'm confused because one link I found (
http://stackoverflow.com/questions/2714573/instance-variables-vs-class-variables-in-python)
recommends putting attributes in instances than class.

I guess what I am asking is more of  a Python question than a Django one,
but because Django is actually using this language feature to do something
real-world, I thought of tossing the question here.

Regards,
Ankush Thakur

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALX%3DrK%2BgFvXqpew4vk9N6J0SqugWOUM3sjz%3DGHo8yD1b%2BQQG7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to