From: Peter V. <ve...@em...> - 2003-05-07 09:16:58
|
> > I am not sure if this is a bug, or intended behaviour, but the possib= ilty > > to compare an array type object to 'Any' would be very useful for me. > > 'Any' grew up from the C-API, rather than down from the Python design, > so it's not very well thought out. Right now, it is a placeholder use= d > to mark arrays with undefined types and to indicate "no type constraint= " > in C API calls. In normal contexts, you can't make an array of type > 'Any'. I think there are two reasonable behaviors for comparisons with > 'Any', both used in C. The first behavior is literal comparison; her= e > comparison to Any would generally return "not equal". The second > behavior is wild-card matching; here, comparison to Any would generally > return "equal". Which makes sense to you? How do you want to use > this? I use 'Any' right now in C functions to indicate 'no type constraint'. Yo= u=20 could use both literal comparison and wild-card matching behaviour for th= at,=20 if you want to do this in Python, I think. But maybe one should not do su= ch a=20 thing in Python by comparison to 'Any' at all. Literal comparison is what I generally expect from Python objects, so any= thing=20 else may just be confusing (at least to me). However, the name 'Any' does= =20 suggest the wild-card matching behaviour.=20 Is there specific reason why you exposed 'Any' in python? Maybe it would = be=20 better not to expose such a type object since it seems to be a 'special=20 case'. I am starting to think that my use for it at the Python level is n= ot=20 appropiate. For instance, I could easily use 'None' instead, and I think = I=20 will do that in the future.=20 You mentioned that 'Any' is really a C-API thing. Unless somebody has a g= ood=20 use for it I would now actually say that it maybe should not be exposed a= t=20 the Python API level at all... Cheers, Peter =20 --=20 Dr. Peter J. Verveer Cell Biology and Cell Biophysics Programme EMBL Meyerhofstrasse 1 D-69117 Heidelberg Germany Tel. : +49 6221 387245 Fax : +49 6221 387242 Email: Pet...@em... |