On 4/22/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > It's an interesting idea; it's been brought up before but nobody AFAIK > has ever implemented it. I like the scoping requirement. I suggest you > try to implement it and see how well it works.
I'll look into that now that I know it's not a discard idea. > You probably also want to be able to hook list, tuple and dict > displays (perhaps by supplying an alternative factory function). Maybe I've not been awake long enough, but I don't see what I'd want to hook here that isn't already done using a subclass with an overrided __str__ or __repr__ method. On 4/22/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > class MyCompiler(Compiler): > def build_float(self, literal): > return Decimal(literal) > > # Pass this to compile or exec via an ast_compiler argument > # It may even be possible to permit it as an argument to __import__ I definitely like the look of this for the complie/exec usage, but it definitely makes for a more annoying general usage. I'm not sure about the __import__ way, as it smells of spooky effects, but might be a good practical back door to bring a submodule in line. For in-module effect, maybe some special import could pull in a compiler class instance used only for the current module, allowing its build_xyz methods be replaced. from __ast__ import compiler compiler.build_float = Decimal # on an instance, so no 'self' parameter If something like that sounds reasonable for usage, I'll start looking into how it looks for implementation. (Probably a big ball of mud! And sounds like it depends on the python-side interface to the ast - I've lost track if that's solidified yet.) :) Michael -- Michael Urman http://www.tortall.net/mu/blog _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com