|
Python and Apacheby Peter Laurie, coauthor of Apache: The Definitive Guide, 3rd Edition04/10/2003 |
As part of the improvements we made to the third edition of Apache, the Definitive Guide, we covered the interface between Apache, the major scripting languages, and a database manager.
For some reason, we left out Python--a perfectly good language, with some useful features of its own--so here is what we should have said in the book.
Python is freeware and you can download it from www.python.org. I downloaded version 2.2.2, which seemed to be the latest stable release. There is an executable for Windows and source code for Unices, in the usual way. I took the Unix version and compiled it under FreeBSD.
Once I had downloaded, compiled, and installed Python I discovered I was a complete novice in the language. But if you check out the Beginners Guide on python.org, you will find several adequate tutorials. I learned enough to carry out this exercise in an hour or so.
(You can also download the manuals. In the world of freeware, where no one is paid to do the tiresome work of presenting user-friendly material, you get over 700 files without, as far as I could see, an index. But, hey!)
Next, I needed an interface between Python and MySQL, which I downloaded from zope.org. The only installation problem was the simple matter of telling it not to use the thread-safe library because my version of FreeBSD is flaky on threads.
So far, so good.
The Apache config file was simple enough:
User webuser
Group webgroup
ServerName www.butterthlies.com
DocumentRoot /usr/www/APACHE3/site.python/htdocs
ScriptAlias /cgi-bin/ /usr/www/APACHE3/cgi-bin/
DirectoryIndex /cgi-bin/script.py
As usual, the User and Group that Apache will run as are set to be unimportant and powerless. This is so hackers who penetrate Apache's defenses will find themselves unable to do anything interesting on the server.
The next three lines in the code above are obvious enough, and the last invokes our Python script, script.py, when we browse to the URL www.butterthlies.com.
The script assumes we have a database of people with Christian names (SQL column name xname) and surnames (SQL column name sname). The idea is to put up an HTML form where you specify a Christian name. The script then looks it up and prints the full names of everyone that fits.
The script is:
1 #! /usr/local/bin/python
2 import _mysql
3 import sys
4 import regex
5 def ask_for_name():
6 print "content-type: text/html\n\n"
7 print "<form action='/cgi-bin/script.py'\
8 method=POST>\
9 Which Christian name would you like to search\
10 for?<BR>\
10 <input name='xname' type='text' length=30><BR>\
11 <input type=submit value='Go'>\
12 </form>"
13 def get_name(indata):
14 print "content-type: text/html\n\n"
15 print "got: ",indata,"<BR>"
16 b=regex.search("=",indata)
17 c=indata[b+1:len(indata)]
18 print c
19 a="select xname,sname from people where xname='"+c+"'"
20 print a,"<BR>"
21 db.query(a)
22 r=db.store_result()
23 while(1):
24 a=r.fetch_row()
25 if(len(a)):
26 print "Christian name:",a[0][0], "Surname:\
27 ",a[0][1],"<BR>"
28 else:
29 break
30 # open a database
31 db=_mysql.connect(host="localhost",user="webserv",\
32 db="people")
33 indata=sys.stdin.readline()
34 if(len(indata)):
35 get_name(indata)
36 else:
37 ask_for_name()
38 print "done it all"
|
Related Reading
|
(The lines are numbered here for reference only.)
Line 1 is the "shebang" line that makes the shell load Python and run the rest of the script. Lines 2 through 4 import Python modules, including the new _mysql, which we'll need later.
Line 5 defines one of the two functions. An oddity of Python is that it does not use the squiggly braces that C or Perl employ to mark out code blocks. Python does it by indentation, so you will notice that lines 6 through 12 have moved right one tab. This may have seemed a cute idea when Python was first conceived, but I imagine it might get a bit tiresome. For example:
If you change the ordering of the code you have to change the indentation on every line affected, rather than just moving the end braces.
If a line runs over (and this depends on your editor) you have to end it with a "
\" to make the next line read on. You, reading this as HTML, may get the effect twice because your screen may make the lines fold yet again.If the indentation is out of whack by just one space, the code may fail in some mysterious way.
This function simply prints the HTML for a little form to stdout. Apache sends it to the client, where you see:
Which Christian name would you like to search for?
<search box>
<Go button>
done it all
Line 6 sends the essential HTML header. Without that, you would be looking at a blank screen.
Line 7 sets up the form with the action /cgi-bin/script.py; that is, the server is to execute this same script again.
done it all is printed by line 38 after execution has returned from the function.
Lines 13 through 29 form the second function, and we will come back to them.
Execution starts at lines 31 and 32, which open the database.
Line 33 reads from stdin and puts the result in the variable indata. If we are on the first pass through the script, stdin will be empty, since the client hasn't yet sent us a Christian name. The if at line 34 will fail, and we will get to the function ask_for_name() at line 37.
If we are on the second pass, the if will succeed because indata contains some data, and we will go to the function get_name(), with indata as the argument. Line 14 again prints the HTML content-type line to stdout.
Line 15 prints indata so that we can see that eveything is working properly. If the client wants to find every "John," for example, you should see:
Got: xname=John
It is sensible to give the HTML input field the same name as the corresponding column in the SQL table. We now have to split indata into name and value. If we had a more complicated form, we would first have to split it into name=value pairs.
Line 16 invokes Python's regex module and searches indata to find the character =. (I would have preferred to use the split() function, but it didn't work, and I didn't have the time to find out why. See page 331 of Apache: The Definitive Guide, 3rd Edition for Perl's Regex split(), which handles the same problem.)
search() returns a number b; the position of the = sign (in this case, b=5). The desired Christian name then starts at position b+1, and that is what c is set to in line 17. We print it at line 18 to make sure we have it correctly.
Line 19 sets up the SQL search query. The + signs are Python's concatenation commands, so we end up with a set to:
select xname,sname from people where xname='john'
We print it at line 20 and query the database with it at 21. Line 22 stores the result in the variable r.
We start a perpetual while() loop at line 23, and extract the database returns record by record into a.
If we have a database return to print, a will be full and non-zero in length. Line 25 tests for this and if we have a record, line 26 prints it. a[0][0] is the first field, the Christian name, and a[0][1] the second, the surname. (In Perl and PHP, the returns from a database query are nicely indexed by their field names. It is possible that this interface offers such a feature if you dig hard enough.) If a is empty, we break out of the loop at line 29 and return from the function. Line 38 then shows that everything has finished properly.
Once you have this skeleton working, it should be easy enough to elaborate it to do a useful e-commerce job.
Is Python the language for a first-timer? I'm not sure. It is a solid piece of work, properly organized and developed, and is, happily, without some of the annoying quirks of Perl. On the other hand, its odd indentation syntax is unlike any other language, so you will eventually have to unlearn it. I get the impression it is not much used for CGI scripts, so although it will probably work (as it does above), it may lack some of the bells and whistles other languages offer.
However, as we recommend in the book, if you don't know a language and do know someone who can guide you through the brambles, and their language is Python, then yours might well be too.
Peter Laurie is the coauthor of Apache: The Definitive Guide, 3nd Edition
O'Reilly & Associates recently released (in December 2002) Apache: The Definitive Guide, 3rd Edition.
Sample Chapter 11, "Security," is available free online.
You can also look at the Table of Contents, the Index, and the full description of the book.
For more information, or to order the book, click here.
Return to the Apache DevCenter.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 31 of 31.
-
To the pompous assholes commenting about peter's work.
2005-12-14 12:46:02 coreyhaskin [Reply | View]
-
To the pompous assholes commenting about peter's work.
2008-12-27 23:37:51 anarsist [Reply | View]
Looks very interesting, great guide guys keep up the good work. Thanks for sharing. Regards,
khaos (http://www.khaos.info/) forum (http://www.khaos.info/forum/) edebiyat (http://www.khaos.info/edebi-mevzular/) Felsefe (http://www.khaos.info/felsefe/) HiAxySheytan (http://hiaxysheytan.com/)
-
retract this article
2004-09-26 00:58:55 helopilot [Reply | View]
Please retract this article. It is so amateurish that it's insulting.
Basically any author should do his/her homework before publishing a technical article. One hour to learn a language and publish a working Python script is all but impossible. This article proves my point.
Sorry - but shoddy work is just that.
-
Welcome to Python
2003-04-28 15:56:46 anonymous2 [Reply | View]
Hi Peter, and welcome to the world of Python. I'm sorry people have been so hard on you here. Pythonistas are usually very mild tempered and friendly. I hope they haven't made you feel all negative to this great language.
To be honest, your article might fit better as a mail to the python-tutor mailing list asking for improvements, than as an introduction to python for people who don't know it.
The current python standard documentation is online here: http://www.python.org/doc/current/
The central document once you get through the tutorial is the module reference, and be sure to read chapter 2 (Built-in Functions, Types, and Exceptions) well. It can be found here: http://www.python.org/doc/current/lib/lib.html and there is an index of standard modules at http://www.python.org/doc/current/lib/modindex.html and a full index at http://www.python.org/doc/current/lib/genindex.html
It's not too poorly organized, is it? As usual, it takes some time to learn where to look.
Of course, this is all too much to absorb in an hour, but Python can be a very useful tool for a long time, so it might be worth more than an hour or so to learn.
As others have pointed out, regex is obsolete, and not meaningful here anyway, and _mysql is internal, and normally nothing you use in your code. The kosher Python way is to use the DB-API 2 interface, MySQLdb.
I suggest you get the MySQL module at the source, http://sourceforge.net/projects/mysql-python instead of at Zope.
I think the tutorial at http://www.devshed.com/Server_Side/Python/CGI/print_html handles just everything you went into: Regular Expressions (but for real), cgi and MySQL.
It also introduces some helpful stuff you skipped, like the cgi module. Might I also suggest that you add "import cgitb; cgitb.enable()" in the beginning of your code. It helps with debugging...
Good luck with Python in the future.
/Magnus Lyckå
-
please: take 2 days to learn python and use mod_python
2003-04-28 00:41:02 anonymous2 [Reply | View]
Hi!
Really embarassing. But, of course, not everybody can know every programming language.
But then you had better asked someone else to assist you in Python/Apache integration.
BTW: Creating a working script in 1 hour is excellent. It is ugly, but it is working.
Maybe your comments should only have been:
"I created a working script in one hour, wow!
I'm sure there's a much more pythonic way
to to it, but it least it is working."
Please, take one or 2 days and read a Python tutorial:
Python is programming made easy and fun!
I've been developing software for twenty years now.
From basic to forth and assembler
to pascal and c and c++ and java
(and lisp, on the university).
I tried perl once. It is powerful, but
very hard to learn (basically because of the odd syntax).
Making some simple modifications in a simple script (HTTPD.zip user authentication) took me several days!
Then I discovered Python. It's been the first time since my first Sinclair Basic programs (thanks, Sir Clive!) that learning a new programming language was really fun!
It has all those little features that you ever dreamed of as a programmer.
If you had known Python earlier than Perl,
do you think you would have learned it?
I don't think so. After 4 hours (hint: never use less than half a day for playing around with a new programming language) I'm pretty sure you would have thought:
* Why is Perl so cryptic where Python is so clean?
* Why do I have to use braces?
* Hmm, the available libraries are almost the same as in Python.
I hope that universities will use Python in programming education more and more.
Henning von Bargen
-
Article not well informed
2003-04-26 21:39:47 anonymous2 [Reply | View]
No offense, but I'm a Python newbie and have not really used regexes, yet even I know one should use the re module. Heck, Python even gives you a warning about it:
>>> import regex
C:\Programming\ActivePython\Scripts\pycrust:1: DeprecationWarning: the regex module is deprecated; please use the re module
#!/usr/bin/env python
You mention getting split() to work was impossible. Here's my try:
>>>"Name=John".split('=')
['Name', 'John']
>>>"Name=John".split('=')[1]
'John'
You criticize the syntax, mentioning people would have to unlearn indenting when learning a different language? Not true IMO. They should KEEP indenting, but they'll find they're required to add parentheses or BEGIN/END or whatever to it. If anything, it teaches good programming practice. I know, as a beginner I wrote programs in other languages which I didn't indent because it wasn't necessary. I obviously ended up regretting that.
You also mention the burden of having to place "\" to continue long lines. Someone already pointed out that in many cases this isn't even necessary (particularly what you're doing in line 7 is quite pointless). But anyway, I'd rather add a character to that handful of wide lines I have than a ";" after *every single line*.
After showing how little you really know about Python (even though you do succeed in making a working script from scratch with no prior knowledge in an hour), you tell that it misses bells and whistles. Considering that you didn't even find index.html in the docs directory, I doubt you'd know a bell from a whistle in Python if they both hit you on the nose. By the way, you'll be happy to know that Python has a nice help() function which displays documentation on functions, modules, etc. Give it a try, I find it quite handy.
I hope you take the time to correct your article.
-
Bad Python Code
2003-04-23 09:42:49 anonymous2 [Reply | View]
Apart from the predjudices that were already critizized, the Python code just plain sucks:
'regex' was deprecated ages ago in favour or 're'. _mysql shouldn't be used at all, as the leading underscore shows. It's the backend for the MySQLdb module. Using MySQLdb, especially with cursorclass=dictcursor will make the code much more readable.
<Insert MySQL-sucks comment here>
-
indentation
2003-04-17 07:22:57 anonymous2 [Reply | View]
Scoping via indentation is not unique to python e.g. occam uses this technique. Indentation (like folding editors) grows on you.
-
I was going to buy the book this weekend.
2003-04-16 06:50:09 count0 [Reply | View]
But if this is the same level of research and quality of writing that the book contains, the book is a waste of paper. Rather than actually taking a day or two to evaluate the software he hacks together a script (which does real work), and then declares that python isn't perl or c.
Interesting observation.
Then rather than saying "Look I did real work in a new language in an hour that involved multiple areas of technology!", he said indenting is boring.
I wish ORA made all of their authors do extensive articles about topics in the author's books so we can judge the quality of the author before we shell out forty bucks at borders or bn. You should advertise it like "find out if this author sucks with his online article repository at http://..."
It might even make the authors make sure that they are beyond a novice in a technology before evaluating and presenting an athorative opinion on it.
-
Indenting "Cute"
2003-04-15 11:35:58 anonymous2 [Reply | View]
"This may have seemed a cute idea when Python was first conceived, but I imagine it might get a bit tiresome."
You may not agree with or like the use of indentation to define block structure, but the decision to make white space significant was not based on cuteness. It was well and carefully thought out, and decided upon because it makes code easier to read. Programs of almost any size should be indented anyway, and getting rid of brackets cuts down on visual noise.
I indent all my code anyway (or let my editor do it) and I have no problems with it. In fact, I prefer it. My experience mirrored Eric Raymond's:
"Oddly enough, Python's use of whitespace stopped feeling unnatural after about twenty minutes. I just indented code, pretty much as I would have done in a C program anyway, and it worked." (Source: http://www.linuxjournal.com/article.php?sid=3882)
-
Patient Peter
2003-04-15 00:55:24 werner.bruhin@free.fr [Reply | View]
Peter,
While I could not have written that little script in the short time you used I think you should have shown a bit more patient and tried to get to know Python a bit better.
I am not an expert (nor a programmer) but a few things you should note if ever you update this article (I think you should because otherwise, as it does you no favor for e.g. your book sales).
- As you noted Python is open source and there are quite a few ways to get documentation which is searchable and has an index (one I use is Boa and IDE for Python).
- The slash at the end of the line is not required, either tripple quote your string or any type of brackets will do the trick.
- The indentation - Just moving braces is in my view creating crappy code which no one can read, so Python forcing you to follow a BASIC style code is very good. I can only point out that probably just about any IDE will do the indentation just about by itself.
Until I see some other articles from you I will look at other authors first!
Best regards
Werner
-
Comment on annoyed Python enthusiasts
2003-04-15 00:23:50 peterlaurie [Reply | View]
I'm sorry my remarks about Python upset some of the language's enthusiasts.
This was the first program I had ever written in Python, and I spoke as I
found. My normal langaues are 'C' and Perl. Both use braces and their
absence in Python is striking.
My comments were intended, as I said, for people who have not yet decided on
a computer language. It might help them to point out what we perceive as the
pros and cons of the languages we talk about.
-
Comment on annoyed Python enthusiasts
2003-04-28 16:06:21 anonymous2 [Reply | View]
Peter wrote:
"My comments were intended, as I said, for people who have not yet decided on a computer language. It might help them to point out what we perceive as the pros and cons of the languages we talk about."
I hope you will take the time needed to be able to actaully give such suggestions, and then update this article. Maybe it would be good for the next edition of your book. Python is certainly a poor implementation of Perl if that's what you are after, but it has other qualities.
Even if it's very easy to learn (particuarly for people who haven't gotten used to Perl ;) it will naturally take a little time to get proficient. Imagine someone trying to teach people Perl after an hour or so of exposure to the language... :)
-
Comment on annoyed Python enthusiasts
2003-04-25 15:20:02 anonymous2 [Reply | View]
Hi Peter,
We're having a discussion of your article on the Python-Tutor mailing list. Here's a link to the thread:
http://mail.python.org/pipermail/tutor/2003-April/022008.html
The article has stirred up a hornet's nest. *grin*
You are welcome to join us if you'd like to learn more about Python programming:
http://mail.python.org/mailman/listinfo/tutor
Sincerely,
Danny Yoo
-
Not freeware. Open source.
2003-04-14 15:48:55 anonymous2 [Reply | View]
I think the author of this article is getting enough punishment but I have to add something.
Python is not freeware. Is Open Source, Free Software or whichever you would like to call it but is not freeware.
Regarding the lack of an index.html in the html docs you should look better. It's there. And besides, the Python documentation is superb.
The author says:
"If the indentation is out of whack by just one space, the code may fail in some mysterious way."
Python says:
"IndentationError: unindent does not match any outer indentation level"
This doesn't look very mysterious, don't you think?.
And last, why the the heck the author is importing directly _mysql module instead of the correct one MySQLdb?.
-
remove this article
2003-04-14 12:33:38 anonymous2 [Reply | View]
It does no one any favours, especially O'Reilly and Peter Laurie...
-
First python program
2003-04-13 07:22:37 speno [Reply | View]
I can tell this is your first python program. I would ask that the readers not judge too harshly either its author or python by this example. I'm sure my first python program looked bad too.
Making this program more pythonic is left as an exercise for Mr. Laurie.
-
Thanks for saving me $39.95
2003-04-11 11:03:23 anonymous2 [Reply | View]
By giving me a free sample of your poor writing style and your even poorer research skills, I now feel comfortable avoiding the purchase of your $39.95 book. Thanks!
-
Working code in under an hour!
2003-04-11 07:32:31 anonymous2 [Reply | View]
"I learned enough to carry out this exercise in an hour or so."
Isn't it wonderful to be able to produce a prototype quickly? Now when you review the language and code with your Pythonistic peer, you can discuss it over *working* code, not first overcoming syntactic nuances.
I'm certain your second hour will be filled with the joys of Python's built-in datatypes and access techniques.
-
Nonsense re: indentation & usability for CGI
2003-04-11 07:13:36 anonymous2 [Reply | View]
I wish people that have never tried Python for more than 10 minutes would stop writing articles about it. Any Python user knows the indentation "thing" goes away as a "problem" with maybe 4 hours of experience, tops. It's an advantage, not a disadvantage as anyone that's actually used Python well knows.
Also, Python is widely used for both CGI and in general for web apps. It works extremely well for this and has rich standard library support appropriate to this domain.
One last criticism: This article inherits the writer's inexperience with Python and makes Python sound hokey. Not so. Python is a mature and extremely powerful language used in major companies for large projects. The New York Stock Exchange, Google, Philips, Nasa, Rackspace, ILM, Disney, HP, IBM, AstraZeneca and many others use Python extensively.
For details on how Python is really used and what it really can do read this:
http://pythonology.org/success
-
Nonsense re: indentation & usability for CGI
2005-02-10 07:54:12 dor [Reply | View]
I could not agree more.
We are using jython (a version of python for java) in our project, and it is a big success. Identation is not an issue at all. more over it helps you read the program.
D. Orbach
booksprice - one book one click best price
-
Please replace this article with one by a Python advocate
2003-04-11 05:56:22 anonymous2 [Reply | View]
A recent survey of Python Web development frameworks had over twenty entries. The author might find it informative to look at mod_python, a module for integrating Python to Apache. The Zope server can be run standalone, or as a Apache plugin with fastcgi. Some of the more popular web (actually with Python these are also object sharing server) frameworks written in Python include Twisted, Quixote and WebWare.
The author missing an important point about Python. It is extremely easy to learn the language. As he illustrated, it is possible to be productive from the first hour you use it. Please show me someone who could write a meaningful program that interfaces with a database and a web server in less than an hour in any other language. With perl you would still be looking up the meaning of $^, or some other obscure "feature" of the language.
The author suggests indentation as a method for block notation would get tiresome. To the contrary, those who complain loudly about it eventually sheepishly eat their words. It's great fun to see this transformation in their view of the language feature.
If the use of indentation is the worst thing you can say about a language doesn't that suggest something? Indentation of blocks is considered good coding style. A language that enforces good style seems like a good idea.
-
disappointing
2003-04-11 05:24:47 anonymous2 [Reply | View]
please give us examples and not generalizations.
"I get the impression it is not much used for CGI scripts, so although it will probably work (as it does above), it may lack some of the bells and whistles other languages offer."
What makes you think this? What "whistles other languages offer" does Python lack? Curley braces? Continuations? Please elaborate.
What makes you think that Python isnt popular amongst CGI? I understand your context. But mod_python is a project of the apache foundation.
Its unfortunate that python did not make it into Apache definitive guide. Its even more unfortunate that people are so stuck on style when it comes to seeing something mildly different. And isnt it something that most people really shouldnt mind? They indent everything else.
Just try using Python seriously for 2 days. I promise you will not regret it. Even if it takes you 2 hours to get over your learned depedence on {}
-
FUD
2003-04-11 04:12:42 anonymous2 [Reply | View]
Shockingly badly researched for someone in charge of writing "definitive guides". I suppose Python code could be annoying to edit in Notepad, but any decent editor can handle indents/unindents with little effort, and one day of writing and reading Python code will make it obvious that Python's approach nearly guarantees you can read code, as opposed to following Perl/Java sloppily bracketed code.
-
In defence of Python...
2003-04-11 03:21:07 anonymous2 [Reply | View]
OK I'll bite. In defence of Python...
"If you change the ordering of the code you have to change the indentation on every line affected, rather than just moving the end braces."
You have to do that with code written in other languages anyway. If you change the ordering of the code you're going to have to reindent things or your indentation will just be confusing. Every decent programmer I've ever met has indented their code, Python just makes that behaviour part of the language. It ends up being a LOT easier to spot problems due to indentation compared to spotting problems in a brace-denoted language due to a missing brace somewhere.
The indentation thing always crops up when people not used to it take a look at Python. The simple answer is to give it a go - it's remarkably intuitive once you get over the initial shock (I can remember being put off by indentation before I tried Python).
To be fair though, you do need a half decent editor to effectively work with Python. My editor can add / subtract 4 spaces of indentation from a selected block of code when I hit tab / shift-tab. I can't imagine there are many programmer's editors out there that lack this functionality.
"Is Python the language for a first-timer? I'm not sure. It is a solid piece of work, properly organized and developed, and is, happily, without some of the annoying quirks of Perl. On the other hand, its odd indentation syntax is unlike any other language, so you will eventually have to unlearn it."
There's a sizeable movement to get Python more involved in education, and I'm a big supporter of the idea. Python has a very shallow learning curve, teaches good programming practise from the start (proper indentation for one thing) and covers a whole bunch of different programming paradigm. My girlfriend was struggling with Java so I introduced her to Python and she picked it up in less than a week and found her understanding of Java improving as well. The fact that hello world is:
print "hello world"
Is a big bonus as well.
"I get the impression it is not much used for CGI scripts, so although it will probably work (as it does above), it may lack some of the bells and whistles other languages offer."
It's true that it's not used for CGI scripts that much, mainly because mod_python is not yet as stable as mod_perl. Python's indentation rules also make it less of a likely candidate for embedding in HTML, although there are projects that have managed to do this.
As for bells and whistles, take a look at the Python Standard Library :) There aren't many languages that come with modules for ftp, smtp, imap, SGML parsing, DOM and SAX XML, unit testing, building HTTP servers and so on straight out of the box. In fact there are very few bells and whistles that Python /doesn't/ offer.
This post was not intended as a rant, more of an informative overview of details the author may have missed in his brief inspection of Python.
-
retract article
2003-04-11 02:10:44 popat [Reply | View]
> I learned enough to carry out this exercise in an hour or so.
The quality of your writing is very disapointing. Take some time (a day - not an hour) and get yourself familiar with CGI and Python.




From a third-party perspective, I understand why you flamers are mad; a complete Python noob figured it out much faster than you did. You seem like the half-retarded bully on the playground, beating up the kid who tried and succeeded.
I was amazed at what assholes you self-important programming DORKS were to someone who didn't have "correct" Python programming habits. Why didn't you post "proper" code if you are so superior? Think of what other things you could have done instead of flaming him. You could have gotten your overweight, fat-ass up and bought more cigarettes, or even gone out on a date with a "real woman" from an escort service... The possibilities are endless, but you'll never know because you are spreading negativity.
Please don't reproduce. We already have enough assholes.