Language Python
(Creative version)
Date: | 11/06/05 |
Author: | Schizo |
URL: | n/a |
Comments: | 16 |
Info: | http://www.python.org/ |
Score: | ![]() |
'''A more interesting way to get the lyrics to "99 Bottles of Beer on the Wall", in Python. Is this considered cheating?''' import re, urllib print re.sub('</p>', '', re.sub('<br>|<p>|<br/> |<br/>','\n', re.sub('No', '\nNo', urllib.URLopener().open('http://www.99-bottles-of-beer.net/lyrics.html').read()[3516:16297])))
Download Source | Write Comment
Alternative Versions
Version | Author | Date | Comments | Rate |
---|---|---|---|---|
This example demonstrates the simplicity | Gerold Penz | 07/23/05 | 15 | ![]() ![]() |
Advanced, extensible beer/wall framework | Jamie Turner | 05/17/06 | 7 | ![]() ![]() |
minimal version | Oliver Xymoron | 04/20/05 | 5 | ![]() ![]() |
using lambda in LISP style | J Adrian Zimmer | 11/14/06 | 2 | ![]() ![]() |
Exception based | Michael Galpin | 02/08/08 | 0 | ![]() ![]() |
functional, w/o variables or procedures | Ivan Tkatchev | 07/14/05 | 2 | ![]() ![]() |
minimal version with singular | Emlyn Jones | 06/13/05 | 3 | ![]() ![]() |
Fully compliant version | Ricardo Garcia Gonzalez | 01/15/06 | 7 | ![]() ![]() |
Using a iterator class | Eric Moritz | 01/20/06 | 2 | ![]() ![]() |
New conditional expressions in 2.5 | Ezequiel Pochiero | 12/18/06 | 1 | ![]() ![]() |
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
I beleive this is not cheating.
OK. 10 for uber-geekness. 1 for utility. I'm kicking the tires on scripting languages right now. I've been an OO Java developer for 10 years (since 1.1.3beta) but the weakest link in my tool box is lack of a scripting language. So looking at this side-by-side with Ruby, Groovy, et al. does me no good.
import urllib, re
w = '99 bottles of beer on the wall'
t = urllib.URLopener().open('http://www.99-bottles-of-beer.net/lyrics.html').read()
print re.sub('<[^>]+>','\n', t[t.index(w+', 99'):t.rindex(w)+len(w)])
It checks for the opening of the song and the end of the song, and takes everything inside of it. Not as short as the supplied version, but a bit more robust.
I betcha the other languages couldn't do the same in so few lines.
This one sure is great