Fredrik Lundh wrote: > Nick Coghlan wrote: > >>> The person whose 'complaints' I was stating says that DSLs (Domain >>> Specific Languages for those who, like me, were confused about the >>> acronym) are a big part of what he is after and one per interpreter is >>> fine by him. He also realises that the application(s) he needs them >>> for might be unusual. He doesn't specifically need the builtin types >>> to be extendable. It's just nice to be able to define a single class >>> in multiple modules. Even C++ allows this to some extent (but not as >>> much as he'd like). >> I'm somewhat confused as to how Python's classes aren't open. Sure, types >> like >> the builtin types that don't have a __dict__ aren't open because there isn't >> anywhere to put the extensions, but metaclassing lets you do whatever you >> want >> to any other class: > > you don't even need metaclass trickery to deal with the "define a single > class in multiple modules" problem; just use multiple inheritance to bring > all the component classes together.
I didn't mean to say that I thought what I posted was a sensible thing to do - I was mainly curious as to how close I could get to Ruby's class extension syntax by using metaclasses (with the answer being "very", IMO). If someone really wants to extend a Python class, they can just define a function that does what they want and assign it to whatever method names on whatever mutable classes they feel like. No fancy syntax needed :) Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com