Programari Lliure

IronPython Studio, Resolver, Python Papers & IronPython Talks

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
Recently most of my blog entries have been on IronPython or Resolver (my apologies). It has been an important few weeks for Resolver, with our beta now out and the announcement that Resolver will be free for personal/Open Source use:Resolver One Beta Now Live! - and available for free downloadResolver Sponsoring PyCon - gold sponsors no less, and a good chance I will be able to attend!Resolver Hacks Update - articles and examples (IronPython code) of using ResolverPyCon 2008: IronPython and Resolver Talks! - it will be a good PyCon for IronPythonIronPython in Action: New Chapters and WPF - new IronPython in Action chapters available and WPF from IronPythonACCU 2008 Conference: Dynamic Languages on .NET - I'll be doing a talk on IronPython at the UK ACCU conference in April 2008Big Resolver News: New Beta, Release Date and Resolver Free for Personal UseResolver, IronPython and the Python Papers and the One Minute Screencast - A new Resolver screencast and interviews with me and Giles Thomas (our dear leader at Resolver) in the Python PapersIronPython Studio: Problems, Victory and Compiled Binaries - Using the WPF and Winforms designers in IronPython Studio to produce compiled executables (plus a couple of minor problems along the way)
Categories: Programari Lliure

IronPython Cookbook Updates

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
There have been some great new additions to the IronPython Cookbook in recent weeks:Creating XML Trees - Using XML to LINQ features, that are new to .NET 3.5, with IronPythonFile as TextReader - a wrapper class, so that you can use Python files where .NET expects a StreamReader objectExtremely Late Binding - Late bound COM with IronPythonMonthCalendar Control and datetime - Using the Windows Forms MonthCalendar control with Python datetimeListing Time Zones - Listing time zones known to the systemUsing Spreadsheet Functions with Excel 2007 - more COMListing all Exceptions in the SystemPlus the IronPython 2.0A7 files have been added to the Downloads page.
Categories: Programari Lliure

Status: 12/23/2007 and year in review

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
It was a pretty wild year for me. I had a massive health crisis at the beginning of the year, wrote an almost-working compiler for a functional language using SML targetting SPIM, finished up grad school, got married, landed a job at Participatory Culture Foundation, made a lot of new friends, mentored a GSoC project, helped out with GHOP, started the big push for PyBlosxom 2.0, released a new version of Bee Careful, Marvin under a CC BY-NC-SA 3.0 license and submitted my first patch for Firefox 3.0. I started the Nomadic Telecommuting Herd which has regular meetings, but hasn't extended beyond Chris and I, yet. I'll push this more at some point in the spring when it's more fun to go outside. I also joined a few projects that I haven't been able to get to yet like the Python docs project and Geyser. I'm interested in helping out both of them, but haven't found the time yet. This year I want to tame the firehose, get some good work done, participate more in other projects, possibly learn C++ and reach out to other people in the area (Somerville, MA, USA) to get together and hack more. I'd also like to get a new laptop, but the longer I wait, the better the possibilities become.
Categories: Programari Lliure

Hashiwokakero

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
Hashiwokakero (or Hashi for short) is a Japanese puzzle. I discovered it in the back of a magazine at my haircutter, of all places. Like sudoku, it's an abstract puzzle requiring reasoning about a number of constraints at once. The numbered circles are islands, your task is to fill in the bridges connecting them. There can be zero, one or two bridges between each pair of islands, orthogonally. Bridges cannot cross, and the number on the island indicates the number of bridges to the island. Lastly, all the islands must be connected:Indigo Puzzles has the nicest online implementation: not only can you interactively solve the puzzle, but you can ask for advice, and it will patiently explain a possible next deduction, and why. They have lots of puzzles if you join the site (free). BTW: Hashi is one of the puzzles published by Nikoli, a Japanese puzzle magazine with many types of puzzles. 2007-12-23T13:11:32Z
Categories: Programari Lliure

Elisa weekly news #3

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
During this pre-holiday week the Elisa team has been busy working on the new user-interface... Florian hunted a bunch of memory leaks in the MVC and Observer/Observable frameworks. He also found some inside Pigment. This will lead us to a lighter (memory wise) Elisa application. Christophe is hidden below his "monton" of rush-hours-pre-holiday work too, thanks to him and Florian the Elisa UI is really eye-candy-rocking! I finally committed the long-awaited Youtube plugin, it works quite well, using the GData API I previously blogged about. I also did some random fixes in the new frontend. Alessandro has been busy getting the new frontend to work on the Samsung Q1 (which has a nice and large touchscreen), so he polished mouse support for a bunch of widgets. Benjamin worked on playlist display support in the new UI. So you can access current playlist from the "Audio" menu. It's easy to enqueue songs as well. It's not the final integration, but it at least shows that we are aware of some basic features missing in Elisa and that we are doing something about it :) Loïc worked on Python bindings for the matrix transformations he committed previous week. This allows us to do even more bling inside Elisa! Guillaume fixed some Pigment bugs and deadlocks like usual at lightning speed, especially an annoying one about Texts regeneration, thanks Pigment dudes! Lionel played with Pigment matrix transformations to implement some "loading animations" for the new UI, so that during long tasks (like Flickr requests), the UI remains responsive and displays something nice while the user is waiting useful stuff to be displayed :) Lionel is also continuing to hunt bugs and other oddities of the frontend. On the Coherence front, Frank did some Rhythmbox backend hacking and continued to help Morty on the Last.FM backend. I still hope I'll be able to test that before end of the year. :) That's all for this week. Next week should be pretty calm, happy holidays, merry Elisa Christmas! 2007-12-23T12:54:26Z Philippe Normand
Categories: Programari Lliure

WebOb

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
WebOb. WebOb is “an extraction and refinement of pieces from Paste”—provides a very nice request and response object, clearly inspired partly by Django. The documentation includes the differences between the WebOb API and that of other frameworks. 2007-12-23T10:22:45Z
Categories: Programari Lliure

GObject is everywhere

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
Spent the day on OLPCGames today. I'm trying to clean up the code so that the various pieces can be used independently to let people code for the OLPC without giving up portability (and I was hoping, to get GTK totally out of the picture for people n... 2007-12-23T00:33:14Z mcfletch
Categories: Programari Lliure

My blog woes have been soothed

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
It seems I've mostly solved my "blog woes". I got some quite helpful replies (still visible on Blogger, although the comments didn't come over to my new blog). I also got emails from Will Guaraldi about PyBlosxom, and from Lloyd Dalton about blog_my. I took at least a brief look at each system mentioned in the comments and emails, but I decided on PyBlosxom. If you're reading this in a web browser, what you're seeing is PyBlosxom rendering a theme I ported from Tumblr, with all of my old Blogger blog's content imported. Quite frankensteinian indeed, as far as blogs go. It turns out that my impression of PyBlosxom's size when I wrote my "blog woes" post was a bit off - I didn't realize just how little functionality resides in the core. It's pretty slim, but with a decent selection of plugins. I only needed tags, wbgarchives, and metadate, but there are plenty more for those who want more features. With the tag and metadate plugins, I managed to keep my blog posts in almost exactly the format I've always used, so that was nice. PyBlosxom nicely solves my biggest concern, which I didn't explicitly state in my original post: I want to keep all of the files related to my blog in a Mercurial repository. I've succeeded in that - my entire blog is in Mercurial now. That includes configuration files, the .htaccess file, the template, the entries, and even the queue of unfinished entries. If I ever need to, I should be able to move the blog to another host in a matter of minutes. Not that I ever intend to leave WebFaction (note: that's an affiliate link), which is where it's happily hosted now. With that all out of the way, hopefully I can quit the detestable practice of metablogging, which I'd managed to avoid for my entire first year. Thanks to everyone who made a suggestion, and special thanks to the PyBlosxom developers. 2007-12-23T00:05:00Z
Categories: Programari Lliure

The power of checklists (especially when automated)

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
Just stumbled on this post at InfoQ on the power of checklists. It talks about a low-tech approach to improving care in hospitals, by writing down the steps needed in various medical procedures and putting together a checklist for each case. I've seen the power of this approach at my own company -- until we put together checklists with things we have to do when setting up various servers or applications, we were guaranteed to skip one or more small but important steps.I'd like to take this approach up a notch though: if you're in the software business, you actually need to AUTOMATE your checklists. Otherwise it's still very easy for a human being to skip a step. Scripts don't usually make that mistake. Yes, a human being still needs to run the script and to make intelligent decisions about the overall outcome of its execution. If you do take this approach, make sure your scripts also have checks and balances embedded in them -- also known as tests. For example, if your script retrieves a file over the network with wget, make sure the file actually gets on your local file system. A simple 'ls' of the file will convince you that the operation succeeded.As somebody else once said, the goal here is to replace you (the sysadmin or the developer) with a small script. That will free you up to do more fun work.
Categories: Programari Lliure

The End of an Era

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
CompUSA closing?  It's a bit hard to believe it.  I remember going there back in the 80's, for goodness sakes.  Bought lots of books and software there, not to mention keyboards, mice, memory, cases, motherboards, you name it.  They've been around for about as long as I've been a programmer.  Now where am I going to buy motherboards when the old one dies on a Saturday morning? True, I've been buying most of my peripherals from Circuit City these days, but they don't carry very many motherboards, and none of them in stores.  It seems that computer shows are a dying breed these days, too. I guess there are too many places to buy assembled computers these days, and the gamers and other people who like to customize buy their parts online.  Ah well.  A cup of auld lang syne, CompUSA, we knew thee well.
Categories: Programari Lliure

64k version of python is 4234x faster* than c-python!

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
To satisfy some sick curiosity of mine, I decided to write a miniature version of python in less than 64k of code. The code includes a tokenizer (which works rather well) a parser (which sort of works ) a translator (which does the job). All of those bits are written in python. [...]
Categories: Programari Lliure

This Week in Django - Podcast

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
If you haven't already seen it, check out Michael Trier's new podcast "This Week in Django". The first episode was good, so I'm looking forward to listening to the second.Subscribed!
Categories: Programari Lliure

PyMOTW: zipimport

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
The zipimport module can be used to import and run Python code found inside ZIP archives.Module: zipimportPurpose: Load Python code from inside ZIP archives.Python Version: 2.3 and laterDescription:The zipimport module implements the zipimporter class, which can be used to find and load Python modules inside ZIP archives. The zipimporter supports the "import hooks" API specified in PEP 302; this is how Python Eggs work.You probably won't need to use the zipimport module directly, since it is possible to import directly from a ZIP archive as long as that archive appears in your sys.path. However, it is interesting to see the features available.Example:For the examples this week, I'll reuse some of the code from last week's discussion of zipfile to create an example ZIP archive containing some Python modules. If you are experimenting with the sample code on your system, run zipimport_make_example.zip before any of the rest of the examples. It will create a ZIP archive containing all of the modules in the zipimport example directory, along with some test data needed for the code below.Finding a Module:Given the full name of a module, find_module() will try to locate that module inside the ZIP archive.import zipimportimporter = zipimport.zipimporter('zipimport_example.zip')for module_name in [ 'zipimport_find_module', 'not_there' ]: print module_name, ':', importer.find_module(module_name)If the module is found, the zipimporter instance is returned. Otherwise, None is returned.$ python zipimport_find_module.pyzipimport_find_module : not_there : NoneAccessing Code:The get_code() method loads the code object for a module from the archive.importer = zipimport.zipimporter('zipimport_example.zip')code = importer.get_code('zipimport_get_code')print codeThe code object is not the same as a module object.$ python zipimport_get_code.py at 0x57530, file "./zipimport_get_code.py", line 28>To load the code as a usable module, use load_module() instead.importer = zipimport.zipimporter('zipimport_example.zip')module = importer.load_module('zipimport_get_code')print 'Name :', module.__name__print 'Loader :', module.__loader__print 'Code :', module.codeThe result is a module object as though the code had been loaded from a regular import:$ python zipimport_load_module.py at 0x57968, file "./zipimport_get_code.py", line 28>Name : zipimport_get_codeLoader : Code : at 0x57968, file "./zipimport_get_code.py", line 28>Source:As with the inspect module, it is possible to retrieve the source code for a module from the ZIP archive, if the archive includes the source. In the case of the example, only zipimport_get_source.py is added to zipimport_example.zip (the rest of the modules are just the .pyc files).importer = zipimport.zipimporter('zipimport_example.zip')for module_name in ['zipimport_get_code', 'zipimport_get_source']: source = importer.get_source(module_name) print '=' * 80 print module_name print '=' * 80 print source printIf the source for a module is not available, get_source() returns None.$ python zipimport_get_source.py================================================================================zipimport_get_code================================================================================None================================================================================zipimport_get_source================================================================================#!/usr/bin/env python## ... some lines omitted for brevity ...#import zipimportimporter = zipimport.zipimporter('zipimport_example.zip')source = importer.get_source('zipimport_get_code')print sourcePackages:To determine if a name refers to a package instead of a regular module, use is_package().importer = zipimport.zipimporter('zipimport_example.zip')for name in ['zipimport_is_package', 'example_package']: print name, importer.is_package(name)In this case, zipimport_is_package came from a module and the example_package is, well, a package.$ python zipimport_is_package.pyzipimport_is_package Falseexample_package TrueData:There are times when source modules or packages need to be distributed with non-code data. Images, configuration files, default data, and test fixtures are just a few examples of this. Frequently, the module __path__ is used to find these data files relative to where the code is installed.For example, with a normal module you might do something like:import osimport example_packagedata_filename = os.path.join(os.path.dirname(example_package.__file__), 'README.txt')print data_filename, ':'print open(data_filename, 'rt').read()The output will look something like this, with the path changed based on where the PyMOTW sample code is on your filesystem.$ python zipimport_get_data_nozip.py /Users/dhellmann/Documents/PyMOTW/in_progress/zipimport/example_package/README.txt :This file represents sample data which could be embedded in the ZIParchive. You could include a configuration file, images, or any othersort of non-code data.If the example_package is imported from the ZIP archive instead of the filesystem, that method does not work:import syssys.path.insert(0, 'zipimport_example.zip')import osimport example_packageprint example_package.__file__data_filename = os.path.join(os.path.dirname(example_package.__file__), 'README.txt')print data_filename, ':'print open(data_filename, 'rt').read()The __file__ of the package refers to the ZIP archive, and not a directory. So we cannot just build up the path to the README.txt file.$ python zipimport_get_data_zip.pyzipimport_example.zip/example_package/__init__.pyczipimport_example.zip/example_package/README.txt :Traceback (most recent call last): File "zipimport_get_data_zip.py", line 41, in print open(data_filename, 'rt').read()IOError: [Errno 20] Not a directory: 'zipimport_example.zip/example_package/README.txt'Instead, we need to use the get_data() method. We can access zipimporter instance which loaded the module through the __loader__ attribute of the imported module: import syssys.path.insert(0, 'zipimport_example.zip')import osimport example_packageprint example_package.__file__print example_package.__loader__.get_data('example_package/README.txt')$ python zipimport_get_data.pyzipimport_example.zip/example_package/__init__.pycThis file represents sample data which could be embedded in the ZIParchive. You could include a configuration file, images, or any othersort of non-code data.Although __loader__ is not set for modules not imported via zipimport.References:PEP 273 - Import Modules from ZIP ArchivesPEP 302 - New Import HooksPython Eggsinspect modulePyMOTW: inspectPython Module of the Week HomeDownload Sample CodeTechnorati Tags:python, PyMOTW
Categories: Programari Lliure

Speeding up dateutil: Python's heapq module turns minutes into seconds

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
Speeding up dateutil: Python’s heapq module turns minutes into seconds. Neat case study in data structure optimisation. 2007-12-22T13:07:43Z
Categories: Programari Lliure

String comparison function in Python (alpha)

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
I was working on a unittest which when it failed would say "this string != that string" and because some of these strings were very long (output of a HTML lib I wrote which spits out snippets of HTML code) it became hard to spot how they were different. So I decided to override the usual self.assertEqual(str1, str2) in Python's unittest class instance with this little baby:  def assertEqualLongString(a, b):     NOT, POINT = '-', '*'     if a != b:         print a         o = ''         for i, e in enumerate(a):             try:                 if e != b[i]:                     o += POINT                 else:                     o += NOT             except IndexError:                 o += '*'        o += NOT * (len(a)-len(o))         if len(b) > len(a):             o += POINT* (len(b)-len(a))        print o         print b        raise AssertionError, '(see string comparison above)' It's far from perfect and doesn't really work when you've got Unicode characters that the terminal you use can't print properly. It might not look great on strings that are really really long but I'm sure that's something that can be solved too. After all, this is just a quick hack that helped me spot that the difference between one snippet and another was that one produced
and the other produced
. Below are some examples of this utility function in action.[145 more words] 2007-12-22T11:00:00Z
Categories: Programari Lliure

Software is written by hand

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
...that's right, it's not molded or prefabbed, it's not made on a production line or in a lab. Are we insane??! Here is a hilarious probe into the darker side of this art we call programming. 2007-12-21T22:02:06Z
Categories: Programari Lliure

Converting ReStructuredText to Wiki syntax

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
I just released a little package called wikir that attempts to convert reStructuredText to Wiki syntax. Why? Mostly because I have a lot of projects hosted on Google Code and reStructuredText is my documentation weapon of choice. It's also widely supported in the Python world, The Cheeseshop, pydoctor, etc. The 0.1 release has some very basic things working. Next I hope to add an entry_point that can list modules and their respective wiki files for the publish_wiki command and have that hook into the standard wiki directory of a Google Code repository. 2007-12-21T21:01:24Z
Categories: Programari Lliure

Patterns of Change

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
Reg Braithwaite knows... Of course I recommend reading the original. But may I add, please do not get sucked into arguing whether Design Patterns are good, or whether IDE refactorings really work, or any of the other technical points that are so much fun to rehash for the millionth time. Instead, consider the cultural forces at work. Cultural problems cannot be solved with technology. If you are an advocate for change, ask yourself what sort of cultural change is needed, not what sort of technical problems need to be solved.
Categories: Programari Lliure

The Future Comes in Green and White

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
This week I received two significant packages: my "spit kit" to provide a DNA sample for 23andMe to analyze and my One Laptop Per Child XO-1. I think both of these are landmarks. I'll report on both over the coming months. Here are some more photos: 23andMe Spit Kit OLPC XO Unboxing
Categories: Programari Lliure

You Me Us We Named Top Song of 2007

Unofficial Planet Python - Dll, 24/12/2007 - 04:55
Back in May, I wrote about the song You Me Us We which was originally an instrumental piano piece of mine to which Nelson Clemente later added vocals as part of our Nelson James collaboration. For Nelson's solo debut EP, I worked with producer Rob Agostini on an electropop version that was described by one reviewer as "the perfect blend of sparkly pop that will make you feel like the world isn't so bad after all". The site ElectroQueer has always been a fan of the song but they just released their Top 120 Songs of 2007 and guess which song ended up at #1! Thank you Nelson and Rob and ElectroQueer for making a simple piano piece I wrote as a 19-year-old into an international number one pop song!
Categories: Programari Lliure
Contingut sindicat