Is count supposed to still work?

David LeBlanc whisper at oz.net
Fri Jul 12 16:17:56 EDT 2002


Whether or not you explicitly import string,
	count(mystring, substring)
isn't working ("NameError: global name 'count' is not defined") (N.B. this
statement is in a method of a class),
but
	mystring.count(substring)
does. However, count is not listed as deprecated in the python 2.2.1 doc.
Even deprecated, it should still work.

FWIW, I wish none of these where deprecated. Maybe it's incorrect, but I
tend to think of an attribute of something, not something's attribute. Both
ways are useful IMO. Sometimes len|count|int|float(thing) is nice and
sometimes
thing.len|count|int|float() works better. Not a different way to do
something, a different way to express the same thing.


David LeBlanc
Seattle, WA USA






More information about the Python-list mailing list