What's better about Ruby than Python?

Alex Martelli aleax at aleax.it
Thu Aug 21 04:24:49 EDT 2003


Bengt Richter wrote:
   ...
> This is interesting, because I presume you are happy with properties ;-)

Properties AND many other descriptors, sure.  The whole descriptors
scene is cool, and properties one of the best uses for them so far.


> So is this basically a thing about the global namespace? I.e., if
> we had way to introduce a subclassed module types into the import
> mechanism, we could have module properties, which presumbaly could
> be accessed much like parameterless Pascal functions.

Nothing stops you from hooking the import mechanism and stuffing
class instances in sys.modules -- it's actually very easy in Python
2.3, where your hooks need not interfere with any others (it's just
a beautiful new architecture for hooking imports).

However, I think the simplicity and predictability of modules plays
a useful role.  I've occasionally played with putting instances in
sys.modules but invariably backed out to simpler solutions for the
purpose of putting code in production.  So, I'm not sure "smarter
modules" (able to play with descriptors transparently) would in
fact be an improvement; I'm quite dubious about the issue.


Alex





More information about the Python-list mailing list