Posts matching tags 'python'
2008/1/12
The source code of the classic urban-planning simulation game,
(via alecm, Boing Boing) ¶ [no comments]
2007/12/6
2007/2/28
JavaScript 1.7, the version used in Firefox 2.0, has a raft of Python-inspired features, including generators and list comprehensions. So now, you can do things like:
function fib() {
var i = 0, j = 1;
while (true) {
yield i;
[i, j] = [j, i + j];
}
}
and
var evens = [i for (i in range(0, 21)) if (i % 2 == 0)];And, indeed, bulk assignments, like:
[a, b] = [b, a];That is, as long as you're not concerned about your code working on non-Mozilla web browsers. (I wonder whether Microsoft, who still have well over 80% of the browser market, will adopt these new features.)
2006/8/29
The core developers of Python (a rather elegant open-source programming language, in which, incidentally, this website is written) have broken ground on Python 3000, the massive, compatibility-breaking overhaul they intend to give Python, fixing the mistakes, shortcomings and inelegancies in the current version. Here are the things that will change, and here are the things that won't.
It's heartening to see that lambda functions (once slated to be abolished) have been given a reprieve. Otherwise there would have been no concise way of passing anonymous functions as a data type, and instead of being able to do something like (to quote a rather silly example):
greeters = {
'english' : lambda name: "Hello, %s"%name,
'french' : lambda name: "Bonjour, %s"%name,
'australian' : lambda name: "G'day, %s"%name
}
one would have to take the long way around, doing something like:
def greet_english(name): return "Hello, %s"%name
def greet_french(name): return "Bonjour, %s"%name
def greet_australian(name): return "G'day, %s"%name
greeters = { 'english': greet_english, ... }
And I don't buy the argument that anonymous functions are bad form, and that each chunk of code should have a name that describes what it does. There are many instances where one wants to specify a tiny fragment of code which will fit into a larger mechanism like a small but crucial cog (be it in a function call, a data structure or wherever), without the bureaucratic overhead of giving it a name. Otherwise we may as well be programming in Java or COBOL or some Vogon-designed abomination of a language.
2005/10/5
Civilization IV, the latest in the highly addictive game series, is coming soon, and looks interesting; other than the gameplay, it will be extensively customisable using XML-based data and Python scripting. Ht's probably just as well that there is an organisation such as Civilization Anonymous; I suspect they'll be busy.
(via worldchanging, 433) ¶ [3 comments]
2005/4/26
Nifty Python hack of the day: a C-style switch() construct, implemented without using dictionaries (instead using a class and yield).
(via pythonurl) ¶ [no comments]
2005/4/6
A post on teaching one's children to program in Python:
your_name = raw_input("What's your name? ")
if your_name.lower() == "freja":
print "You're very stinky,", your_name
else:
print "You smell lovely, ", your_name
Which sounds like the next generation's equivalent of 10 PRINT "JASON IS ACE!" 20 GOTO 10
2005/3/1
My latest gift to the world's collection of marginally useful software: x64spriterip, a quick and dirty Python script which pulls sprite images out of Commodore 64 emulator memory dumps and writes them to PGM files. Just in case you ever felt like grabbing some graphics from your favourite childhood computer game for a chat-room avatar or T-shirt logo or somesuch but couldn't be arsed writing the software to do it yourself.
2005/1/29
Glyph Lefkowitz is not only the developer/prime mover of an impressively elegant Python-based network programming framework, but has also written some nuanced and insightful essays about various topics, including a good argument for extending Python rather than embedding it (i.e., there are many good reasons other than laziness for it), a righteous excoriation of the Ayn Rand Institute's take on the "War on Terrorism", and a very astute attempt at a framework for ethics in software development, which does a good job of unmuddying the waters. Go and read.
2004/12/16
TinyP2P, a (not particularly scalable) peer-to-peer file-sharing application in 15 lines of Python. Expected to be printed on T-shirts by cypherpunk dissident types when such programs become illegal, while the rest of the world shrugs, says "those geeks are weird" and gets back to their Trusted Computing pay-per-play Windows Media singles.
2004/10/31
This looks fairly nifty: Unununium, a thoroughly modular operating system, following the principle that the utility of a system is proportional to the number of connections possible between its components. It's implemented in Python (the kernel contains a Python interpreter), consists of small pieces, loosely joined, and also aims to be completely persistent (so that the machine's state is retained when it is powered off). And, of course, probably won't take the world by storm, though could well become the next Oberon. (via gimbo)
2003/7/31
Python 2.3 is officially out, and brings with it lots of features. Generators are now a first-class part of the language (and not part of __future__), which allows a sort of lazy evaluation; Python can import modules from ZIP files; there is the enumerate() function, which allows you to iterate over a sequence's indices and values more efficiently, as well as Set and Boolean types; and there are a number of nifty new modules, such as a correct CSV handler, and more. Oh, and it's apparently 25% faster too.
2003/2/11
An internal memo from Sun about what's wrong with Java:
- The support model seems flawed
- The JRE is very large.
- Extensions do not support modularity.
- It is not backward-compatible across minor releases.
Interestingly enough, the memo goes on to compare Java to Python, with Java coming out of it not looking very good.
2003/1/15
The Year in Scripting Languages, a roundup of what happened in 2002 in the worlds of Python, Perl, Ruby, Tcl and Lua.
(Lua? Oh yes, it appears to be a new embedded scripting language of Brazilian origin. No idea what it looks like, as the site doesn't actually show any code.)
"Forget about Basic and go for Lua! Lua is just as easy to use, but a lot more powerful. Lua is also very easy to extend."
-- Jon Kleiser, in comp.sys.mac.programmer.help.
2003/1/3
Via Richard's blog, a USENET rant on why XML is evil. It meanders a bit, in the classic crackpot sense (the extension of the metaphor of XML as a bad child into a reference to diaper fetishism, segueing into a digression on why Americans like big breasts, is but one example), but I must say I agree somewhat with the sentiment; to whit, XML is useful as a markup language for text, but putting everything in XML (as some are advocating) is just silly. For one, for most things, there is too much syntactic overhead compared with other formats, and the idea seems to suffer from the Microsoft Fallacy (i.e., the assumption that clock cycles are too cheap to care about and may be squandered at will).
(I was thinking recently of the data format for a project I've been working on (more info on that later), and was toying with making it XML-based; after all, everybody else is doing it, aren't they? Though I'll probably make it some sort of Python-like pseudocode notation, or something otherwise lighter.)
2002/9/15
Psyco, a just-in-time compiler for Python. Unlike most JIT compilers, it's a specializing compiler, meaning that it makes several versions of each function, optimised for different data sets. The author claims it can accelerate Python algorithmic code to C-like levels of speed, obviating the need to write C modules. (via NtK)
2002/6/21
2002/5/12
Two Python bits: Deadly Bloody Serious about Python, a new Python-related blog. (via gimbo) And Bridgekeeper, a program for translating Perl code to (variously odd-looking) Python code. (via NtK)
2002/4/7
Subterfugue, a system for intercepting and altering system calls from untrusted Linux binaries, scriptable in Python. Get it before it's banned under the SSSCA. (via NtK)
2002/3/15
Nifty: A program which locates found haiku in text files. Well, found senryu, to be precise. (It needs Python 2.2, as it uses generators.) (via bOING bOING)
2002/2/28
This is cool: Gadfly, a reasonably efficient SQL database module for Python, written entirely in Python (with optional C extensions) and using portable data files. I think Zope might make some use of it too. Mind you, I can't help but think that they could have made it more lightweight by getting rid of SQL text parsing and having a procedural interface for queries. (via gimbo)
2002/2/18
2002/2/11
This looks really interesting:
Alphabet Soup, a Python program which generates randomly strange-looking
letterforms from elements and a grammar.
Currently it works with fragments of bitmaps, but a vector-based version is
planned.
(ta, Toby)
2002/2/3
An article about the state of Cocoa support under Python. In short, some progress is being made with pyobjc (and Python 2.2's improved object system), but it's not there yet.
2002/1/3
Python 2.2 now has iterators and generators, like some of the more outré functional languages (not to mention Ruby and SuperCollider). Here is a good tutorial.
2001/8/13
Equivalence of Perl and Python imminent? Gun nut and Pythonista Eric S. Raymond wants the two projects to merge their bytecode interpreters, possibly bringing in other languages, such as Ruby and Intercal, to combat Microsoft's all-devouring .NET. The advantages could possibly include the ability to use class libraries across languages, and perhaps even a unified Perl/Python/Ruby/Intercal class library, and the ability to compile any of these languages to C from bytecode (something that apparently is doable in Perl). (via NTK)
2001/3/17
Python roundup: An interview with Guido van Rossum, creator of Python, in which he reveals how he wrote the language, and why it will be the next big thing, taking the mantle now held by the popular mutant camel Perl. And if that isn't enough, here's Eric S. Raymond's take:
Ugly programs are like ugly suspension bridges: they're much more liable to collapse than pretty ones, because the way humans (especially engineer-humans) perceive beauty is intimately related to our ability to process and understand complexity. A language that makes it hard to write elegant code makes it hard to write good code.
I agree with ESR; Perl has its uses for quick file parsing jobs, but isn't really suited to large programming tasks (especially when there are better languages). Python is currently my favourite language for day-to-day use. I've looked at Ruby briefly, and it looks possibly more elegant than Python (some of the OO syntax reminds me of SuperCollider on the Mac), though isn't yet quite as mature as Python.
2001/2/25
You can now get Python for the PalmPilot. Awesome... Mind you, you need a newer Palm than my old Pilot (that's right; not even a PalmPilot; though it does have the 2.0 ROM and 1Mb of RAM).
2000/9/30
This looks most interesting: Python WebWare; not as heavy as Zope, but it has some interesting-looking components such as Python Server Pages and WebKit.
2000/8/16
There's an interesting discussion on Slashdot about how human languages influence programming languages, and how languages designed by non-English-speakers would differ from ones designed by English-speakers. (Oddly enough, some of the most elegant recent programming languages come from non-English-speaking countries; Ruby and Python, for example, are of Japanese and Dutch origin, respectively, while Perl is very American. What does this say about the clarity of the English language?)