Is count supposed to still work?
Alex Martelli
aleax at aleax.it
Fri Jul 12 16:45:39 EDT 2002
David LeBlanc wrote:
> 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.
I don't know what you're talking about. Python has never had a
builtin called 'count'. If you import string, then you can call
string.count -- that's not a global name of your current module,
of course, but rather a global of module string, i.e., an attribute
of module string.
> something, a different way to express the same thing.
Exactly what we DON'T want in Python -- the ideal, alas
unreachable, would be to have *ONE* way to express one thing.
Alex
More information about the Python-list
mailing list