Checking length of each argument - seems like I'm fighting Python
Mike Erickson
mee at quidquam.com
Sat Dec 3 19:25:55 EST 2005
* Brendan (spam4bsimons at yahoo.ca) wrote:
[...]
> Is there a simpler way to check that either all arguments are scalars,
> or all are lists of the same length? Is this a poor way to structure
> things? Your advice is appreciated
Disclaimer: I am new to python, so this may be a bad solution.
import types
def __init__(self,x,y,z):
isOK = False
if ( (type(x) == types.IntType) and (type(y) == types.IntType) and (type(z) == types.IntType) ):
isOK = True
if ( (type(x) == types.ListType) and (type(x) == types.ListType) and (type(x) == types.ListType) ):
if ( (len(x) == len(y)) and (len(x) == len(z)) ):
isOK = True
HTH,
mike
More information about the Python-list
mailing list