Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Python

(Creative version)

Date:11/06/05
Author:Schizo
URL:n/a
Comments:16
Info:http://www.python.org/
Score: (3.04 in 512 votes)
'''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

VersionAuthorDateCommentsRate
This example demonstrates the simplicityGerold Penz07/23/0515
Advanced, extensible beer/wall frameworkJamie Turner05/17/067
minimal versionOliver Xymoron04/20/055
using lambda in LISP styleJ Adrian Zimmer11/14/062
Exception basedMichael Galpin02/08/080
functional, w/o variables or proceduresIvan Tkatchev07/14/052
minimal version with singularEmlyn Jones06/13/053
Fully compliant versionRicardo Garcia Gonzalez01/15/067
Using a iterator classEric Moritz01/20/062
New conditional expressions in 2.5Ezequiel Pochiero12/18/061

Comments

>>  Daniel said on 03/10/06 06:07:13

Daniel I'm giving you five stars, just for being a smartass.

>>  forrestcupp said on 07/31/06 15:05:51

forrestcupp Yeah, that's cheating

>>  2kzombie said on 05/07/07 20:59:17

2kzombie Thats just ingenius. In simplicty we trust, code is great ;)

>>  Grega said on 12/18/07 23:11:34

Grega TOP GEEK :)

>>  byeTwo said on 01/01/08 20:23:39

byeTwo In-genius.
I beleive this is not cheating.

>>  Wes said on 02/10/08 11:25:41

Wes Honestly now, I would say congrats on pulling off a smart-ass method, but it doesn't have any tolerance for error, so for that reason alone I'm going to give a rating of 3. Nice concept, none-the-less.

>>  Anirudh said on 03/02/08 10:44:55

Anirudh nice, but if the source code or the site design is changed even the slightest bit, your code won't work.

>>  Brad said on 03/08/08 22:01:08

Brad
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.

>>  Andrew said on 05/01/08 08:28:44

Andrew Smartass version for sure!

>>  Dylan said on 05/05/08 00:31:57

Dylan winrar

>>  Timothy Soehnlin said on 09/21/08 23:33:54

Timothy Soehnlin A more robust version could be:

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.

>>  OHAI said on 11/30/08 17:02:06

OHAI BAWHAHAHAAHHAHAW

>>  ParadoxGreen said on 03/29/09 09:09:33

ParadoxGreen Excellent concept!
I betcha the other languages couldn't do the same in so few lines.

>>  Jonny said on 04/12/09 02:31:06

Jonny I belive making a version that will have the rules changed, is a badge of honor.
This one sure is great

>>  CountRob said on 06/14/09 02:54:48

CountRob The best program on this site, period. Done the true hacker way.

>>  Bla said on 03/05/10 20:49:57

Bla Hahahahahaa! But you need Internetacces to run this program. ;-)

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!

Name:

eMail:

URL:

Security Code:
  
Comment: