len() should always return something
Dr. Phillip M. Feldman
pfeldman at verizon.net
Fri Jul 24 02:35:43 EDT 2009
Some aspects of the Python design are remarkably clever, while others leave
me perplexed. Here's an example of the latter: Why does len() give an error
when applied to an int or float? len() should always return something; in
particular, when applied to a scalar, it should return a value of 1. Of
course, I can define my own function like this:
if isinstance(x,int) or isinstance(x,float): return 1
But, this shouldn't be necessary.
View this message in context: http://www.nabble.com/len%28%29-should-always-return-something-tp24639361p24639361.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list