Hi Curtis,
The catch is that a hint isn't always possible - or the only reasonable
hint would be redundant.
For example:
ERROR: max_length exceeds 100.
HINT: Make max_length less than 100.
The hint doesn't actually clarify anything above what the error message
already tells you. You can see this in the 1.6 validation framework - In
the case where the connection between the problem and the solution aren't
obvious (e.g., adding related_name to avoid a collision), a hint is
provided, but in other cases, the problem points directly at the solution.
So - hint isn't strictly *required* - it's just highly recommended when
appropriate.
So - how to implement this in Python? If we could enforce the use of
keyword arguments, then the syntax would always read "Error('message',
hint=None)", which is explicit; the problem is that we can't really do
that; we have to allow hint as the second argument, which leaves the door
open to "Error('message', None)" - syntactically legal, but not exactly
expected.
The only way I can see to implement this "properly" is to have Error()
accept **kwargs, and do the argument processing ourselves (i.e.,
specifically look for the hint kwarg). While this is possible, it's more
messy than the alternative, IMHO.
Russ %-)
On Thu, Feb 6, 2014 at 9:35 AM, Curtis Maloney
<[email protected]>wrote:
> I disagree.
>
> If a hint really ought be provided, but can be omitted in the right
> circumstances, it should be a required value.
>
> This will encourage people to provide a hint, or deliberately omit one.
>
> Seems more Explicit and Implicit to me... explicit intention to omit a
> hint?
>
> --
> Curtis
>
>
>
> On 6 February 2014 11:04, Florian Apolloner <[email protected]>wrote:
>
>>
>>
>> On Thursday, February 6, 2014 12:31:43 AM UTC+1, Carl Meyer wrote:
>>>
>>> > However, I can see how this might be slightly contrary to expectation
>>> > for Python developers generally. I'd be interested in hearing other
>>> > opinions on this.
>>>
>>> I don't think there's a reason to require the argument; if `None` is a
>>> valid value for the argument, then clearly it is semantically optional,
>>> so give it a default of `None` and make it actually optional.
>>>
>>
>> +1, Either make it completely required (eg don't allow None) or let None
>> be the default.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers" 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 http://groups.google.com/group/django-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/2880d3fe-10a9-4270-830a-0e362fea0e09%40googlegroups.com
>> .
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" 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 http://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CAG_XiSDyLTfyFbZNqrKHr3jA8b4W0Ay8fHf0a%3DCJdFY0kRMbyg%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"Django developers" 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 http://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/CAJxq84_W3%3D6igr1MZp%2BOq9pRzHsSbTNZX0eTOgA_9SKe4Jkt_g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.