If you have access to the source of the function you want to call (and know
what kind of data types it wants in its args) you can raise something else for
bad parameters, eg:
class ArgTypeError(TypeError):
def __init__(self,
On Mon, 2006-03-06 at 20:25 -0800, James Stroud wrote:
Fredrik Tolf wrote:
If I have a variable which points to a function, can I check if certain
argument list matches what the function wants before or when calling it?
Currently, I'm trying to catch a TypeError when calling the function
Fredrik Tolf wrote:
# ...
if callable(f):
try:
f(*cv[1:])
except TypeError:
self.reply(err, argno)
# ...
However, this results in bugs in the server code that would cause
TypeError to reply to the client that it had the wrong number of args,
and I can't see
Fredrik Tolf wrote:
On Mon, 2006-03-06 at 20:25 -0800, James Stroud wrote:
Fredrik Tolf wrote:
If I have a variable which points to a function, can I check if certain
argument list matches what the function wants before or when calling it?
Currently, I'm trying to catch a TypeError when
Fredrik Tolf wrote:
On Mon, 2006-03-06 at 20:25 -0800, James Stroud wrote:
Fredrik Tolf wrote:
If I have a variable which points to a function, can I check if certain
argument list matches what the function wants before or when calling it?
Currently, I'm trying to catch a TypeError when
James Stroud wrote:
(snip)
Since python is weakly typed,
s/weakly/dynamically/
(snip)
--
bruno desthuilliers
python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Tolf python-list@python.org wrote:
If I have a variable which points to a function, can I check if certain
argument list matches what the function wants before or when calling it?
Currently, I'm trying to catch a TypeError when calling the function
(since that is what is raised when
Roy Smith wrote:
Fredrik Tolf python-list@python.org wrote:
If I have a variable which points to a function, can I check if certain
argument list matches what the function wants before or when calling it?
Currently, I'm trying to catch a TypeError when calling the function
(since that is
If I have a variable which points to a function, can I check if certain
argument list matches what the function wants before or when calling it?
Currently, I'm trying to catch a TypeError when calling the function
(since that is what is raised when trying to call it with an illegal
list), but
You can match if the list contains the legal number of arguments with.
func_variable.func_code.co_argcount
Type checking arguments has to be done manually since Python is a
dynamic language. Perhaps, you could try some typechecking decorators.
http://www.ilowe.net/software/typecheck/
From the
I will be out of the office from March 3rd to March 31st.
In urgent cases please contact [EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 6, 2006, at 8:44 PM, James Stroud wrote:
Since python is weakly typed, you will not be able to check what
type of arguments a function expects. TypeErrors relating to the
type of argemtns you pass will be raised inside the function only and
not when it is called. I.e. there is no
Jay Parlar wrote:
On Mar 6, 2006, at 8:44 PM, James Stroud wrote:
Since python is weakly typed, you will not be able to check what
type of arguments a function expects. TypeErrors relating to the
type of argemtns you pass will be raised inside the function only and
not when it is
13 matches
Mail list logo