Comment On Real Coders Don't Need Drivers

Today feels like a great day to revisit this classic post from Stian Søiland. The good news is that, since originally posting this way back in July of '04, I have only seen one or two other variations of this driver-less SQL sent in ... [expand full text]
« PrevPage 1 | Page 2Next »

Re: Real Coders Don't Need Drivers

2006-02-13 14:25 • by FIRST
FIRST.  wow, im cool

Re: Real Coders Don't Need Drivers

2006-02-13 14:26 • by Frederik
Well, at least it worked... kind of...

Re: Real Coders Don't Need Drivers

2006-02-13 14:26 • by Frederik
59966 in reply to 59964
Anonymous:
FIRST.  wow, im cool


No, you have too much free time ;)

Re: Real Coders Don't Need Drivers

2006-02-13 14:33 • by Meeeee
4th place! not bad...

Re: Real Coders Don't Need Drivers

2006-02-13 14:34 • by toxik
wow.



that's all I'm going to say.

Re: Real Coders Don't Need Drivers

2006-02-13 14:35 • by Randolpho

WTF??!?


This guy is obviously an old-sk00l shell scripter who has just learned python. I've seen stuff like this as a BASH script too many times to count.

Re: Real Coders Don't Need Drivers

2006-02-13 14:36 • by jart
The sad thing is how often this happens. I was hired once to rewrite the back-end a non-functional adult website (no puns intended). The Perl scripts the last 60-an-hour consultant wrote were littered with backticked calls to MySQL.

Re: Real Coders Don't Need Drivers

2006-02-13 14:47 • by What the fag
Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland. The good news is that, since originally posting this way back in July of '04, I have only seen one or two other variations of this driver-less SQL sent in ...



When asked to fix an application here at the university that lets students create their own mailinglists, I stumbled over this python script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the author has discovered a way to avoid compiling a MySQL driver for Python - by using the "mysql" shell tool and parsing the output by splitting it by whitespace. (This will of course fail if anything resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Alex Papadimoulis:

Today feels like a great day to revisit this classic post from Stian Søiland.
The good news is that, since originally posting this way back in July
of '04, I have only seen one or two other variations of this
driver-less SQL sent in ...



When asked to fix an application here at the university that lets
students create their own mailinglists, I stumbled over this python
script that tries to synchronize database entries with Mailman.


In addition to exploring how to create ugly code with Python, the
author has discovered a way to avoid compiling a MySQL driver for
Python - by using the "mysql" shell tool and parsing the output by
splitting it by whitespace. (This will of course fail if anything
resembling a space is present in the database)


Also notice the creation of mysql_cmds.txt for stuff to be executed by the SQL server.



My apologies for the image; they didn’t have HTML syntax highlighting invented back when I originally posted this.

Re: Real Coders Don't Need Drivers

2006-02-13 14:51 • by R.Flowers

Can someone port this to Windows for me? [:P]


(I see that one way or another, the forum software is going to have to change...[8-)])

Re: Real Coders Don't Need Drivers

2006-02-13 14:57 • by Daniel T
This could be a useful trick if you're using an obscure scripting language that really doesn't have MySQL drivers >:-)

--Daniel T

Re: Real Coders Don't Need Drivers

2006-02-13 15:04 • by Umm
So I guess reposting old WTF's is a good way to say he's run out of real coding errors?

Re: Real Coders Don't Need Drivers

2006-02-13 15:06 • by pmagill
59978 in reply to 59976
Wow, did the author of one of the WTF's get pissed at Alex or something?

Regretfully changing the software won't keep this from happening.  Even if you are required to sign up first this guy can sign up, post get banned and sign up again using yet another msn or hotmail address.

____________
I am that signature virus, propogating in an assited manner.

Re: Real Coders Don't Need Drivers

2006-02-13 15:09 • by Daniel T
A co-worker pointed out to me... Judging from the setting, it was probably some poor kid fresh out of Programming 101 with no clue about database libraries, getting paid $5/hour to build this script. If it was in an professional/enterprise/production setting, fine, it's a WTF - in this case, it's probably just a clever student.

--Daniel T

Re: Real Coders Don't Need Drivers

2006-02-13 15:10 • by Daniel T
59980 in reply to 59979
One more comment ;-)

That screenshot is from EditPlus, isn't it? I love it!!!!

--Daniel T

Re: Real Coders Don't Need Drivers

2006-02-13 15:20 • by Nate
This guy probably heard that "Python is a scripting language" so he's using it as a replacement for #!/bin/sh instead of the full-featured programming language that it is.

Re: Real Coders Don't Need Drivers

2006-02-13 15:24 • by R.Flowers
59983 in reply to 59978

Anonymous:
Wow, did the author of one of the WTF's get pissed at Alex or something?

Regretfully changing the software won't keep this from happening.  Even if you are required to sign up first this guy can sign up, post get banned and sign up again using yet another msn or hotmail address.

____________
I am that signature virus, propogating in an assited manner.


Slightly more sophisticated software could weed out excessive repetitions, maybe. Also, just a line of code could get rid of those Javascript "injections."

Re: Real Coders Don't Need Drivers

2006-02-13 15:30 • by makomk
59984 in reply to 59970
Anonymous:
The sad thing is how often this happens. I was hired once to rewrite the back-end a non-functional adult website (no puns intended). The Perl scripts the last 60-an-hour consultant wrote were littered with backticked calls to MySQL.


Yes, but that's Perl - backticked calls to external programs are a long-standing tradition (albeit in this case a WTF-worthy one). Python makes you jump through slightly more hoops to do the same thing (and probably with good reason).

Re: Real Coders Don't Need Drivers

2006-02-13 15:33 • by merreborn
59985 in reply to 59978
Anonymous:

Regretfully changing the software won't keep this from happening.  Even if you are required to sign up first this guy can sign up, post get banned and sign up again using yet another msn or hotmail address.



Slash ( http://en.wikipedia.org/wiki/Slash_%28weblog_system%29 ) does a very good job at filtering out trolls. 

Re: Real Coders Don't Need Drivers

2006-02-13 15:35 • by Pete from Perth
Alex Papadimoulis:

by using the "mysql" shell tool and parsing the output by splitting it by whitespace. (This will of course fail if anything resembling a space is present in the database)


For what it's worth, the MySQL shell tool outputs tab separated values. So the script won't "fail if anything resembling a space is present in the database", just if there's a tab.

Re: Real Coders Don't Need Drivers

2006-02-13 15:40 • by makomk
59987 in reply to 59983
R.Flowers:

Slightly more sophisticated software could weed out excessive repetitions, maybe. Also, just a line of code could get rid of those Javascript "injections."



You wish. For example, I took a look at the LiveJournal code, and while the comment-parsing code is fairly secure (due to a paranoid HTML parser and rewriter) it had a number of additional checks required to handle web-browser specific quirks in parsing HTML, which obviously only got added in response to people noticing security holes. Also, anything short of a full parser (ideally whitelisting), preferably rewriting the HTML in an unambiguous fashion, probably won't cut it reliably due to various... interesting tricks involving HTML entities, comments, punctuation and the like.

Re: Real Coders Don't Need Drivers

2006-02-13 15:43 • by squirrel
59988 in reply to 59976
Anonymous:
This could be a useful trick if you're using an obscure scripting language that really doesn't have MySQL drivers >:-)

--Daniel T


... as opposed to a language whose selling point is integration with the database at the web server.  Lets not forget that this code isn't running anywhere near a backend.  This code runs where UI is rendered.  :)


Re: Real Coders Don't Need Drivers

2006-02-13 15:46 • by squirrel
59989 in reply to 59988
squirrel:
Anonymous:
This could be a useful trick if you're using an obscure scripting language that really doesn't have MySQL drivers >:-)

--Daniel T


... as opposed to a language whose selling point is integration with the database at the web server.  Lets not forget that this code isn't running anywhere near a backend.  This code runs where UI is rendered.  :)


Haha, my apologies to the Python coders (really!).  I don't know why I read this post as PHP.  Maybe the syntax coloring <g>.

Re: Real Coders Don't Need Drivers

2006-02-13 15:50 • by frzx
59990 in reply to 59986
Anonymous:

For what it's worth, the MySQL shell tool
outputs tab separated values. So the script won't "fail if anything
resembling a space is present in the database", just if there's a
tab.




Except the script uses .split(), not .split('\t'), so it will split fields on any whitespace, not just tabs.

Re: Real Coders Don't Need Drivers

2006-02-13 15:55 • by foxyshadis
59992 in reply to 59973
R.Flowers:

Can someone port this to Windows for me? [:P]


(I see that one way or another, the forum software is going to have to change...[8-)])


Amusingly, as long as you have a cygwin/mingw compile of mailman sitting in c:\usr\local\mailman (or whatever your system drive is), this python script would work just fine, fwiw. :p (Unless they're shell scripts, guess you'd have to replace them with batch files that ran them inside the cygwin environment.)

Thankfully I can't see whatever got posted, and I don't really care anyway as long as it isn't another goatse. But I am a bit worried that next up is IE/ActiveX exploits.

Re: Real Coders Don't Need Drivers

2006-02-13 15:57 • by pmagill
59993 in reply to 59989
and r. flowers, I find your avatar a bit umm, disturbing.

Not that that is a bad thing.

I think the only way to be rid of things like this is to deny all javascript and html and just simply block text all replies.  Even then you won't have a decent way around repeated lines in a post or even for someone to copy the entire first chapter of a novel into the post and upload, no repitition is necessary.  This then leads to the question of how long can a post get before you truncate it?  There is no perfect answer.


CAPTCHA = register (is someone trying to tell me something?)

Re: Real Coders Don't Need Drivers

2006-02-13 16:10 • by R.Flowers
59994 in reply to 59993

Anonymous:
and r. flowers, I find your avatar a bit umm, disturbing.

Not that that is a bad thing.


I think I will change it. He's starting to disturb me, too. I found him by doing a Google image search for "WTF."

Re: Real Coders Don't Need Drivers

2006-02-13 16:14 • by makomk
59995 in reply to 59992
foxyshadis:

Thankfully I can't see whatever got posted, and I don't really care anyway as long as it isn't another goatse. But I am a bit worried that next up is IE/ActiveX exploits.


Don't know about that; someone was injecting invisible JavaScript that would quietly post a comment on IE on some of the other forum threads earlier, though. (At least, it would if it actually worked - so many script kiddies just don't test their code properly. I really don't know what the world is coming to...)



Besides, I use Konqueror, so I'm probably safe (you can more-or-less use the forum, as long as you pretend to be an IE user and don't try and use the fancy WYSIWIG HTML editor/toolbar - would it kill them to write portable code for once?).

Re: Real Coders Don't Need Drivers

2006-02-13 16:52 • by Disgruntled DBA
60000 in reply to 59995

would it kill them to write portable code for once?).


Yes.  It was part of the deal that Bill signed with the Devil.

Re: Real Coders Don't Need Drivers

2006-02-13 17:29 • by Carsten Kuckuk

I actually like the general approach for its decoupling qualities:


- No need to link a specific database library into the server


- Easily adaptable to other database CLIs - at least in theory


- Execution time is generally not an issue this days on web servers (unless you run Slashdot or some other popular site)


 

Re: Real Coders Don't Need Drivers

2006-02-13 17:42 • by trollable
60003 in reply to 59982
Anonymous:
This guy probably heard that "Python is a scripting language" so he's using it as a replacement for #!/bin/sh instead of the full-featured programming language that it is.

Now you're just trolling, aren't you?





BTW, does Python have weak references?
I just read an introductary book and there was no mention of this feature.

Re: Real Coders Don't Need Drivers

2006-02-13 17:45 • by an apprentice

I like its highly modular architecture. It seems that /usr/local/mailman/bin/list_lists, /usr/local/mailman/bin/newlist and /usr/local/mailman/bin/rmlist are all separate scripts, called by os.popen and the like. They might be even some bash for all we know.

And intermediate mysql_cmds.txt is probably being created for efficiency reasons - the coder must have thought it's faster to have one call to os.* than thousands. This is optimization gone the absolutely wrong way. But it's nice he put some effort into it...

Re: Real Coders Don't Need Drivers

2006-02-13 18:44 • by Stian Soiland
60007 in reply to 60003
BTW, does Python have weak references?
I just read an introductary book and there was no mention of this feature.

Of course.. the weakref module. It is seldemly used by Python programmers, though, usually only for backend maintenance stuff.


import weakref

class A(object):
    def method(self):
        return 1337

a = A()
a_weak = weakref.ref(a)
# Calling the weakref will reveal the object if it still exists
print a_weak(), a
# <__main__.A object at 0x732d0> <__main__.A object at 0x732d0>
print a_weak().method()
# 1337
a = "Not the A you are looking for"
print a_weak()
# None

Re: Real Coders Don't Need Drivers

2006-02-13 18:50 • by Stian Soiland
60008 in reply to 60004
It seems that
/usr/local/mailman/bin/list_lists, /usr/local/mailman/bin/newlist and
/usr/local/mailman/bin/rmlist are all separate scripts, called by
os.popen and the like. They might be even some bash for all we know.

Yeah.. they are actually Python scripts as well.. but it would obviously take a bit more effort to open the files and read which mailman libraries they were using.

What I like about this code is how they are using "Python" like if it was bash, ignoring every possibility to use a normal database driver or mailman libraries. Of course, using Python instead of say bash will make it a bit easier to split those lists by  [a for a in existing if not a in db_list_names], but that is about the only Pythonish thing in the code - which of course in newer Pythons is done faster and easier by using sets.

Re: Real Coders Don't Need Drivers

2006-02-13 18:58 • by makomk
60009 in reply to 60007
Anonymous:
BTW, does Python have weak references?
I just read an introductary book and there was no mention of this feature.

Of course.. the weakref module. It is seldemly used by Python programmers, though, usually only for backend maintenance stuff.


Full documentation at http://www.python.org/doc/2.4.2/lib/module-weakref.html - as well as Python's standard weak references, there's also weakref proxy objects (which act almost like the actual object referred to - not a good idea to use carelessly, since they might disappear at any moment) and dictionaries with weak keys/values.

Re: Real Coders Don't Need Drivers

2006-02-13 19:01 • by masklinn
60010 in reply to 60003
trollable:
BTW, does Python have weak references?
I just read an introductary book and there was no mention of this feature.

If you're looking for something in Python, first stop is the Global Module Index, always (second one is the standard library reference).


And in the Module Index you can find the Weakref module, introduced in Python 2.1.


(oh, and for the people who don't know python, it has at least 1 or 2 mysql modules, at least one of whom more or less compliant with Python's DB API 2.0)

Re: Real Coders Don't Need Drivers

2006-02-13 19:04 • by jspenguin
60011 in reply to 60003
trollable:
BTW, does Python have weak references?


Yes, it does. Use the weakref module.

Re: Real Coders Don't Need Drivers

2006-02-13 19:07 • by Anonymous Coward
60012 in reply to 60003
trollable:

BTW, does Python have weak references?
I just read an introductary book and there was no mention of this feature.




I don't know - does C or C++?



Re: Real Coders Don't Need Drivers

2006-02-13 19:11 • by Principal Skinner
Python is my favorite general-purpose scripting language (rather fond of JavaScript, but it has pretty narrow applications), but I didn't know about this syntax which still kind of blows my mind:

db_list_names = [a[1] for a in db]

This is definitely not typical Bourne-shell style.  Seems like the bass-ackwards kind of thing that might be possible in Perl, however.

Re: Real Coders Don't Need Drivers

2006-02-13 19:30 • by jspenguin
60014 in reply to 60013
That's a list comprehension. It's equivalent to doing:


db_list_names=list()
for a in db:
db_list_names.append(a[1])

Clearly they've never used pipes

2006-02-13 20:27 • by David
They don't need those temporary files

proc_open -- 
Execute a command and open file pointers for input/output
http://php.net/proc_open

Re: Clearly they've never used pipes

2006-02-13 20:36 • by David
60017 in reply to 60016
oops. Didn't really read the code, beyond noticing mysql and the temp files. not php

Re: Clearly they've never used pipes

2006-02-13 20:40 • by David
60018 in reply to 60017
http://www.python.org/doc/current/lib/module-popen2.html, the python equivalent of php's proc_open

Re: Real Coders Don't Need Drivers

2006-02-13 20:54 • by Gabriel
My goggles! The eyes do nothing! O_o

Re: Real Coders Don't Need Drivers

2006-02-13 22:00 • by Principal Skinner
60023 in reply to 60014
jspenguin:
That's a list comprehension.

Interesting, though I find this concept kind of hard to... um... understand.

Re: Real Coders Don't Need Drivers

2006-02-13 23:35 • by a name
60030 in reply to 60012

I don't know - does C or C++?




C++ - weak_ptr



C - Shouldn't be hard to roll your own, what do you think most of these GC languages are written in?

Re: Real Coders Don't Need Drivers

2006-02-14 00:00 • by M
Probably the original coder didn't have root to install the "official"
MySQLdb  package.  Rather than annoy the sysadmin (or attempt
to install the MySQLdb package in his home directory), he decided to
take matters into his own hands.



Re: Real Coders Don't Need Drivers

2006-02-14 03:45 • by Amanjit Gill

Hey [I] , weren't there license restrictions with using MySQL client libraries - they first changed from lgpl -> gpl, then added the 3 licensing models: foss license, gpl license and commercial license?


For a time being, the situation was gpl for client code. Dunno the exact circumstances today. [^o)]^ Also, efficient bulk importing and exporting are normally not exposed via python db api.


Still WTF - for inserts etc this is weird. And the py is quite ugly. And os.system is very expensive on win32. [N]


 

Re: Real Coders Don't Need Drivers

2006-02-14 04:36 • by Kilroy
60034 in reply to 60023
Then you'll love generator expressions:
gen_exp = (a for a in something if a == 'foo')
will produce a generator which will produce the list of all values in 'something' that is 'foo'. So like a list comprehension but produces its values lazily.

Produce a list from that with list(gen_exp) :)

Re: Real Coders Don't Need Drivers

2006-02-14 06:13 • by Joost_
60038 in reply to 60034

List comprehensions are the gift from god. So many stupid for loops can be stuffed into a little list comprehension. If you want to have a crash course in generator expressions and list comprehensions, take a good look at the results of the Python Coding Contest[1] that was held in the last week of last year; nearly all solutions used three nested generator expressions, except the winning one, which managed to use only two.


On second thoughts, maybe it's not so good for beginning Python coders to look at this code. ;-)


[1] http://www.pycontest.net/ranking/

Re: Real Coders Don't Need Drivers

2006-02-14 07:05 • by dzR
fuck you guys are nerds go play wow or some shit

« PrevPage 1 | Page 2Next »

Add Comment