"has" Operator
Roman Suzi
rnd at onego.ru
Sat Jul 7 17:16:42 EDT 2001
On Sat, 7 Jul 2001, Paul Sidorsky wrote:
>
>I was thinking that Python might benefit from a "has" operator that
>would allow you to type something like this:
>
>if myobject has someattribute:
> foo()
>else:
> bar()
if hasattr(myobject, "someattribute"):
foo()
else:
bar()
is clean enough, IMHO...
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Saturday, July 07, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "OK, I'm weird! But I'm saving up to become eccentric." _/
More information about the Python-list
mailing list