On Thu, 21 Apr 2005 09:59:54 -0500, Larry Bates
<[EMAIL PROTECTED]> wrote:
>2) Or if you not you could see if the argument has next and
>__iter__ methods (more general solution)
>
>if hasattr(arg, 'next') and not hasattr(arg, '__iter__'):
># perform work on iterable
>
>else:
>print "arg m
Charles Krug wrote:
List:
I'm working on some methods that operate on (mathematical) vectors as
in:
def Convolution(x, y)
"""Returns a list containing the convolution of vectors x and y"""
Is there any way to determine at runtime that x and y are iterible
collections?
Do I *coughs* simply *coughs*
Charles Krug wrote:
> List:
>
> I'm working on some methods that operate on (mathematical) vectors as
> in:
>
> def Convolution(x, y)
> """Returns a list containing the convolution of vectors x and y"""
>
> Is there any way to determine at runtime that x and y are iterible
> collections?
>
> D
Charles Krug <[EMAIL PROTECTED]> wrote:
> Do I *coughs* simply *coughs* trap the exception created by:
>
>for v in x:
>
>when v is a scaler quantity?
Sure. Why not? If you're coming from a type-bondage language like
C++ or Java, it probabliy feels strange, but it's the Python way. It
looks
Others may know better ways but the 2 I know of are:
1) If you know that the arguments will be lists or tuples
you can use isinstance().
if not isinsance(arg, (list, tuple):
print "arg must be list or tuple)
2) Or if you not you could see if the argument has next and
__iter__ methods (more g
Charles Krug wrote:
I'm working on some methods that operate on (mathematical) vectors as
in:
def Convolution(x, y)
"""Returns a list containing the convolution of vectors x and y"""
Is there any way to determine at runtime that x and y are iterible
collections?
Do I *coughs* simply *coughs* trap t
List:
I'm working on some methods that operate on (mathematical) vectors as
in:
def Convolution(x, y)
"""Returns a list containing the convolution of vectors x and y"""
Is there any way to determine at runtime that x and y are iterible
collections?
Do I *coughs* simply *coughs* trap the excepti