[Python-Dev] Clean way in python to test for None, empty, scalar, and list/ndarray? A prayer to the gods of Python

Tres Seaver tseaver at palladion.com
Sat Jun 15 15:47:06 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/15/2013 09:15 AM, Donald Stufft wrote:
> I never want to iterate, but I love slice syntax and indexing. Don't 
> think you can have that w/o being able to loop over it can you? Maybe 
> I'm just thinking slow since I just woke up.

You could if '__iter__' raised an error ('NotIterable', maybe) which
defeated the '__getitem__'/'__len__'-based fallback.


Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEARECAAYFAlG8cFoACgkQ+gerLs4ltQ7KcgCfdFCEkp2gBeuUgn/KooY7F5HX
Jm8An2bwq8QoplwJ1MqIbS76m+xdl/Mk
=6hA9
-----END PGP SIGNATURE-----



More information about the Python-Dev mailing list