Python : Items related to the programming and programming language
Updated: 2/27/2004; 9:32:24 AM.

 

Subscribe to "Python" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.

 
 

Friday, February 27, 2004

Oh No! DTO!. Should DTOs have public variables? Or should they have private variables with getters and setters? [Artima Weblogs]

There's an interesting discussion going on in the comments of the blog.  Worth reading - I'm sure we've all pondered this question before.  Especially when you think of languages like Python where it's downright hard (well, at least contrived) to make member variables private.


9:32:12 AM    comment []

Monday, October 13, 2003

ZopeMag Donates Archetypes Article. Mark Pratt sent me a note last week letting me know that the "Introduction to Archetypes" article by Sidnei da Silva is now freely available. Sidnei did a very good job with this article, as did the editors at ZopeMag.[Zope Dispatches]

This looks like a great how-to article explaining how to create products for CMF with the new Archetypes approach.


6:30:21 AM    comment []

Wednesday, September 17, 2003

Python's Beachhead in OpenOffice: PyUNO.

Python can now author OpenOffice components. The new OO 1.1 release includes a Python bridge to its internal UNO framework, an interesting, if obscure, multi-language interop system akin to COM and CORBA. Background briefs mention flaws in the latter which inspired the former. With the new Microsoft Office strategy of subscription-fee services coupled to digital rights management, OpenOffice looks more enticing than ever.

Links: UNO concepts, CORBA comparison chart, UNO details, PyUNO, C++UNO.

[Lambda the Ultimate]
1:15:32 PM    comment []

Monday, August 04, 2003

I've been coding in Python again in my spare time. I miss Lisp a little, but Python is fun because you get alot for free with the huge module library in the base distribution. I still have a long way to go with on the Lisp learning curve, so I'll be back to it one day.

One of the things that Lisp and Python have in common is that functions are fist class citizens along with classes. That means that you can easily mix and match functional, imperative, and object oriented programming styles. This enables some really expressive and powerful programming experiences.

However, all that flexibility can be a bit confusing to me. I recently struggled with the question of when to use a class and when to just use a function nested in a module. After reading through other people's code, wasting alot of time (and getting nowhere) searching the Internet, and talking to peers, I think I've finally got a handle on it. Even if it's not the answer, I'm going with it.

I believe that most of my Python programming should be OO. OO offers and easy way to separate concerns and map concepts to software. However, there are times when OO seems strained to me. In those cases, I'll use module level functions.

An example that comes readily to mind is persisting objects to a data store. Should your classes have methods that save and load themselves? If they do, then the load method is really strained because it has to populate an instance of the class with data. So, that means you instantiate the object and THEN call load. Doesn't this seem wrong? Shouldn't the instance be instantiated by loading the data?

Perhaps you should make a new class that encapsulates the persistence mechanism for the other class. You could have a data store manager that persists your objects. When the data store manager received a load request, it would instantiate the object with the data from the data store and return it to the requester. This seems cleaner. However, the data store manager class doesn't really encapsulate any instance data. So, it's just a bag of methods. Mmm... strained?

This is an example of where I would use a couple of module level functions. One to store the classes that are part of the module and one to load them. This allows me to separate out a behavior that is not really an object action, but is an action on the object. This makes the solution very clean because, to me, there is much less strain on trying to force object interactions.

Whew! Inner conflict resolved. Breathe out... let the code flow...


9:49:09 AM    comment []

Thursday, July 31, 2003

Just found a cool article in the ASPN Python Cookbook about creating a generic thread pool. It seems to be a small, clean implementation.


10:40:48 PM    comment []

Wednesday, July 09, 2003

Andy McKay: Introduction to Plone. Andy McKay from Agmweb Consulting is giving an Introduction to Plone. Plone is an open source content managment system built on CMF and Zope, which I've always thought of as an open source content management tool. Actually, Zope likes to think of itself as application server for content. [Windley's Enterprise Computing Weblog]

Note to self: Check out the latest release of Plone.

Seriously, if you are in to Zope and haven't checked out Plone, you really should. It's a very nice interface on top of the CMF (Content Management Framework). It makes using the CMF much easier and prettier.


4:22:32 PM    comment []

Tuesday, May 20, 2003

PABlog 1.4 released. New version of PABlog, a blog tool for CMF and now plone as well. Changes in 1.4 include better documentation, and adding plone support. It's here. PABlog 1.4 released [Zope.org]
5:27:46 PM    comment []

© Copyright 2004 Tom Pierce.



Click here to visit the Radio UserLand website.

 


February 2004
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29            
Oct   Mar

Search

 
How this works

Emacs Sources
 tsql-indent.el
 user-add-sql-folding-marks
 remove-line-boundary-in-region
 convert-camel-to-underscore

My Subscriptions
 Funny
 KM