Rosetta Code/Count examples: Difference between revisions
Content added Content deleted
m (→{{header|Ruby}}: minor improvement; method names mostly) |
|||
Line 592: | Line 592: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{incorrect|Python|Problem with task "Catmull–Clark subdivision surface" because it contains unicode in the title. See talkpage for traceback.}} |
|||
<lang python>import urllib, xml.dom.minidom |
<lang python>import urllib, xml.dom.minidom |
||
Line 601: | Line 600: | ||
for i in xml.dom.minidom.parseString(x.read()).getElementsByTagName("cm"): |
for i in xml.dom.minidom.parseString(x.read()).getElementsByTagName("cm"): |
||
t = i.getAttribute('title').replace(" ", "_") |
t = i.getAttribute('title').replace(" ", "_") |
||
y = urllib.urlopen("http://www.rosettacode.org/w/index.php?title=%s&action=raw" % t) |
y = urllib.urlopen("http://www.rosettacode.org/w/index.php?title=%s&action=raw" % t.encode('utf-8')) |
||
tasks.append( y.read().lower().count("{{header|") ) |
tasks.append( y.read().lower().count("{{header|") ) |
||
print t.replace("_", " ") + ": %d examples." % tasks[-1] |
print t.replace("_", " ") + ": %d examples." % tasks[-1] |