[Python-Dev] Validators (was Re: Python-Dev Digest, Vol 9, Issue 17) (original) (raw)
Josiah Carlson jcarlson at uci.edu
Tue Apr 6 03:04:54 EDT 2004
- Previous message: [Python-Dev] Validators (was Re: Python-Dev Digest, Vol 9, Issue 17)
- Next message: [Python-Dev] Validators (was Re: Python-Dev Digest, Vol 9, Issue 17)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nature was a horrible word for me to use; what I was trying to convey was that there are so many mays to analyze an object besides just the type (which I assume directly refers to the return value of type(object) as opposed to some loose concept of 'type' as in style) of the object. Like some of the examples I gave earlier, inrange, i.e.:
type(thing) and isinstance(thing, typ) are the only reliable methods we have for determining the "nature" of what an object really is.
In terms of general validation of input, that is also solved by the general decorator syntax. You can wrap your function with any arbitrary argument or return validation as you see fit, if I remember correctly, such decorators are even planned to be in the standard library somewhere.
which is very different from pure type checking which I assume would be:
def func(a: int): pass which simply translates to an 'isinstance(a, int)' call, where 'a' is a variable and 'int' is a type object.
Aside from your "validator" syntax, which I hope /never/ makes it into Python, we understand what you are saying, however, as I said before (and as you didn't listen to), such runtime pre and post validation is currently possible in Python. Certainly it isn't part of the /syntax/ of Python, but I don't believe such type checking or input validation should be a part of Python syntax.
Considering that what you desire is already possible to do, and will be made easier with decorators, what else do you want?
- Josiah
- Previous message: [Python-Dev] Validators (was Re: Python-Dev Digest, Vol 9, Issue 17)
- Next message: [Python-Dev] Validators (was Re: Python-Dev Digest, Vol 9, Issue 17)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]