Then it makes sense to check for number of arguments (len(args) ==
len(obj._meta.fields)) and raise an error if it's not equal to number
of fields. The *args instantiation is useful and fast. QSRF
improvements may make it less useful nut **kwargs instantiation just
always be slower due to the nature of Python.

import this
...
Although practicality beats purity.
...

On 30 янв, 02:57, "Jacob Kaplan-Moss" <[EMAIL PROTECTED]>
wrote:
> On 1/29/08, Ivan Illarionov <[EMAIL PROTECTED]> wrote:
>
> > Jacob, why are you opposed to alternative instantiation methods?
>
>     >>> import this
>     ...
>     There should be one-- and preferably only one --obvious way to do it.
>     ...
>
> On top of that, as I keep saying, it leads to brittle code -- I've
> been bitten a number of times.
>
> For example, say you've got this model::
>
>     class Person(models.Model):
>         first = models.CharField()
>         last = models.CharField(blank=True)
>
> And somewhere -- maybe in a data import script -- you've got::
>
>     p = Person(None, first, last)
>
> Now you decide you need to change you model a bit::
>
>     class Person(models.Model):
>         first = models.CharField()
>         middle = models.CharField()
>         last = models.CharField(blank=True)
>
> Then you run the data import script and get a bunch of people with
> last names stored under ``person.middle``.
>
> Relying on the order of fields in the model definition is asking for a
> heaping load of fail. Hence my desire to see it go away.
>
> Jacob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to