|
From: Andy T. <an...@ha...> - 2006-06-28 11:46:24
|
Alex Tweedly wrote:
> I see in the resourceEditor a line like
>
> if ['List', 'PasswordField', 'TextField',
> 'TextArea', 'Calendar'].count(t):
>
> Is there some subtle difference between that and
> if t in ['List', 'PasswordField', 'TextField',
> 'TextArea', 'Calendar']:
>
> or can I change them to something my mind can more easily read :-) ?
>
From the documentation [1];
count(x)
Return the number of times x appears in the list.
So doing if sequence.count(value): also relies on the fact that zero is
false and non-zero true in Python.
I'd suggest you change it to the 'in' syntax which is more idiomatic and
easier for people like you and I to understand.
[1] http://docs.python.org/tut/node7.html#SECTION007100000000000000000
Regards,
Andy
--
--------------------------------------------------------------------------------
From the desk of Andrew J Todd esq - http://www.halfcooked.com/
|