Challenged by a snake...

Dec 19, 2007 20:37

I needed to learn a bit of Python to help a friend.

I found this site at the same time as I was rummaging around ActiveState's download area.

It's bloody addictive!

...Bert is evil.

bert is evil, python, riddles

Leave a comment

cheesetruck December 20 2007, 01:52:19 UTC
we adopted python at work because we needed a language that was object oriented (despite the fact that I don't do OO) could be run from the shell and also used as cgi. (We have some scripts that actually require pulling data from one server through a php script in order to be parsed... because the guy who wrote them only used php and java. UGH.)

Anyway first thing I did I completed in 3 hours, involved parsing xml (UGH) and writing html; and it worked and I was amazed that it went that well.

2 days later when working with another guy on the same project, just a different part, I discovered we were ACCIDENTALLY documenting our code while writing it. Because python and textmate just cause that to happen.

I've never had a language just work the way python does.

xkcd's cartoon about 2 weeks ago about python? Totally my experience with it.

pydb is a great debugger, I'm liking a bit of win... hmm I forget the name of it but it's a python debugger that is cross platform and starts with 'win' - yeah not a good idea for cross-platform naming (: And ipython is an excellent shell.

parsing xml? elementtree rules.

Only problem I have with it is one guy in the office absolutely refuses to use the modules native stuff and keeps writing wrapper functions around them that do exactly what they do... just taking more memory and wrapping them in needless extra classes and totally unneeded extrapolation of data into specialised objects that would be just fine as tuples, dictionaries, and lists. (yeah I had to rewrite 'hashes' and 'arrays' there in my head - got halfway thru 'ha' before I rewrote it.)

Anyway, I totally dig python.

Paniq did a f*n excellent demo in python+openGL. Totally excellent language.

Reply

myrathi December 20 2007, 03:00:06 UTC
Pretty sure the debugger you're on about is 'winpdb'. At least, I vaguely remember it being platform-independent.

It is rather amusing that anything with a 'win' prefix or suffix is generally automatically assumed to be Winbloze software, though, and not just something with a front-end GUI. :)

It's been heck-knows-how-long since I last had to poke any Python code, so my little foray into that riddle site was a re-eye-opener as to just how damn powerful the language is and how overly complex or disturbingly simplified you can accidentally make code in comparison to other people.

One of the riddles involved finding a hidden graphics file and having a look at it in a hex editor to realise that the content followed a pattern: it was five different graphics files interlaced, byte-by-byte (ABCDEABCDE..etc). The last file was deliberately truncated, based on the header's size info; it could be viewed in Firefox, regardless, but if you wanted to output it properly, you had to pad the end with empty pixels. In most scripting languages, you'd be screwed for ripping those files up with anything short of a few Kb of code. Python? Did it in about a dozen lines - wtf? - and it was only that many because I wanted valid files saved to the drive, with the right extensions and I had to handle the exception thrown by the image library on the last file. Sure, I could've renamed them by hand - but why do what Python can do for you? =) Neat and tidy.

In another example (one of the initial ones, actually), I "created" a solution that I, personally, was rather pleased with. Then I checked out the wiki page for it, to see how other people had done it. My pride? Demolished. My 40+ lines of code were obliterated by, on average, 3 to 5. Sure, I had self-documented as I went along but that still only reduced mine to almost 30. :P A couple of guys had reduced the entire problem to a single line! Bastards! >_< I scratched out my code and started again. Got it to a half-dozen or so the second time around (still haven't entirely got my head around the lambda stuff). Much better. :P

Seriously impressive stuff, though. Impressive enough that I've found myself considering how easily I could replace my PHP sites with it. Erp! >_o

And yes: shifting mental gears on terminology from perl to php to python to whatever other language I happen to have to use/learn each day is always a challenge. Don't even get me started on variations of inline initialization styles (or lack thereof *twitch*).

Programming; gotta love it. Right? :P

Reply

cheesetruck December 20 2007, 10:15:47 UTC
I haven't touched lambda, and, quite frankly, I don't think I shall at work due to the fact that it will mean some folks start using it for extrapolation of things that should be lists into objects containing a list. With a lambda.

Reply

cheesetruck December 20 2007, 10:16:34 UTC
Oh and I noted a forth compiler 2 days ago. I will be attempting to compile this for Amiga and hopefully it will work and let me make a bitchin' 4k (:

Reply

myrathi December 20 2007, 13:00:06 UTC
Which you will then send me. Right? Right.

Awesome.

Reply

cheesetruck December 20 2007, 14:23:03 UTC
of course.

Meanwhile, you HAVE seen the 4k's that Blueberry/Loonies and the other Loonies guys have done on Amiga, right? Oh and the Ephidrena ones.

Ikanim and Finnmark rule.

Reply

myrathi December 20 2007, 17:03:21 UTC
Yes. Maybe. Can't remember.
Yes. Yes.

;)

Reply

myrathi December 20 2007, 12:59:34 UTC
You need to stab that guy in the face with a lambda. :P
The one thing I've noticed is that the core module stuff is written really damn well. And, so far as I can tell, runs reallybloodyquick as-is.

Take his superfluous wrappings and stuff them up his nostrils. On hard-copy. ;P

Reply

cheesetruck December 24 2007, 11:37:56 UTC
Have you looked through the various bits of python ... hmm I forget the term (: I just know #8 is 'suggestions for formatting' and the bit about 'from _future_ import division' - along with the parts about why string templating has been redone recently.

All well thought out and written down. Yeah, I like this. I also like the fact that the hard fast rule is "if it makes sense, do it THAT way, screw the other rules."

Reply


Leave a comment

Up