__getitem__, __getslice__ question for python 2.2

Kragen Sitaker kragen at pobox.com
Wed May 15 15:58:22 EDT 2002


"Raymond Hettinger" <python at rcn.com> writes:
> "logistix" <logstx at bellatlantic.net> wrote
> > Also, some people don't like to use isinstance, but I'm not sure how else
> to
> > tell if you got an int.
> 
> if x != int(x):  print 'expected an integer'

I don't like to use isinstance; I think in this case you should just
use int(theindex), which will raise an exception if the index can't be
represented as an integer.




More information about the Python-list mailing list