[Python-ideas] "on" statement

Robert Madole robmadole at gmail.com
Thu Apr 1 17:15:59 CEST 2010


So I just wrote my 1-gazillionth "if hasattr('method', my_object):" and wanted badly to write this.

	if 'method' on my_object:

I'm not the most experienced Python user, but as far as I can tell hasattr is the preferred way of checking if a method exists.

Please correct me if there is a better way, otherwise I'd like to see what everyone thinks about an "on" statement being added to the Python language.

Thanks,

Rob Madole


More information about the Python-ideas mailing list