Re: Naive question on [min, max] or [min, max)
Ian Bicking <[email protected]> Mon, 30 Jun 2008 12:58:10 -0500
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
保坂範行 wrote:
> Hi.
>
> I have a naive question on min, max of class String in validators.py
> ==
> def validate_python(self, value, state):
> if (self.max is not None and value is not None
> and len(value) > self.max):
> raise Invalid(self.message('tooLong', state,
> max=self.max),
> value, state)
> ==
> why not len(value) >= self.max ?
>
> Python build-in range(start, stop, step), does not have stop in the
> resulting range.
> i.e. range(1. 3) => [1, 2]
>
> I know it may be hard to change now due to impacts to users.
> I felt it bit strange, so I want to know thoughts behind it.
It feels more natural to me, especially given the name "max". That the
max is non-inclusive would be surprising to most people. I thought
about adding a "range" variable which would be like Python and
non-inclusive of its stop, but I never got around to it.
--
Ian Bicking : [email protected] : http://blog.ianbicking.org
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
FormEncode-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/formencode-discuss