Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-25 Thread Kendall Clark
On Apr 23, 2006, at 8:28 AM, Bill Birch wrote: > On Sun, 23 Apr 2006 12:53 am, Fredrik Lundh wrote: >> Guido van Rossum wrote: >>> It's an interesting idea; it's been brought up before but nobody >>> AFAIK >>> has ever implemented it. I like the scoping requirement. >> >> can we add support for

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-23 Thread Bill Birch
On Sun, 23 Apr 2006 12:53 am, Fredrik Lundh wrote: > Guido van Rossum wrote: > > It's an interesting idea; it's been brought up before but nobody AFAIK > > has ever implemented it. I like the scoping requirement. > > can we add support for XML literals while we're at it? > > http://effbot.org/z

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Nick Coghlan
Guido van Rossum wrote: > On 4/22/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: >> No matter what, permitting these kinds of hooks is going to require >> alterations to the process of compiling the AST to the bytecode - and >> subclassing is an excellent way of allowing some aspects of an implementat

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Nick Coghlan
Michael Urman wrote: > 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 'sel

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Fredrik Lundh
Guido van Rossum wrote: > Unfortunately, all of these schemes break down if you have > non-identifier characters in attribute or element names, or if you > want to use namespaces, or if you want to insert entity references, > XML comments, or other funky stuff like DTDs or processing elements. a

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Guido van Rossum
On 4/22/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > Nevow.stan has a very similar method for generating *ML with > (attribute='value')[content], but I've personally found that using only > function-call semantics to create children and attributes for *ML in > Python is much more convenient; all

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > > On 4/22/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > Guido van Rossum wrote: > > > > > It's an interesting idea; it's been brought up before but nobody AFAIK > > > has ever implemented it. I like the scoping requirement. > > > > can we add sup

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Michael Urman
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

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Guido van Rossum
On 4/22/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > > It's an interesting idea; it's been brought up before but nobody AFAIK > > has ever implemented it. I like the scoping requirement. > > can we add support for XML literals while we're at it? > > http://effbot.o

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Manuzhai
> can we add support for XML literals while we're at it? > > http://effbot.org/zone/idea-xml-literal.htm The reason the literals aren't returned as ElementTree Elements is because ElementTree didn't exist back then, right? Because that particular integration would make a lot of sense. Rega

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Fredrik Lundh
Guido van Rossum wrote: > It's an interesting idea; it's been brought up before but nobody AFAIK > has ever implemented it. I like the scoping requirement. can we add support for XML literals while we're at it? http://effbot.org/zone/idea-xml-literal.htm

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Guido van Rossum
On 4/22/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > No matter what, permitting these kinds of hooks is going to require > alterations to the process of compiling the AST to the bytecode - and > subclassing is an excellent way of allowing some aspects of an implementation > to be overridden while

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Nick Coghlan
Guido van Rossum wrote: > On 4/22/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: >> Michael Urman wrote: >>> There's a lot of holes to this story, including at least how these >>> functions are registered, and which additional arguments (if any) are >>> necessary. Shall we try to fill these holes in?

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Guido van Rossum
On 4/22/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Michael Urman wrote: > > There's a lot of holes to this story, including at least how these > > functions are registered, and which additional arguments (if any) are > > necessary. Shall we try to fill these holes in? > > Answering without check

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Nick Coghlan
Michael Urman wrote: > There's a lot of holes to this story, including at least how these > functions are registered, and which additional arguments (if any) are > necessary. Shall we try to fill these holes in? Answering without checking the source (which is undoubtedly a bad idea), but this sou

Re: [Python-3000] Brainstorming: literal construction hooks

2006-04-22 Thread Guido van Rossum
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. You probably also want to be able to hook list, tuple and dict displays (perhaps by supplying an alternative f

[Python-3000] Brainstorming: literal construction hooks

2006-04-21 Thread Michael Urman
This idea isn't fully fleshed out, but I wanted to air it to see if it took wind or fell flat. Please forgive inaccuracies between lexing and parsing. It's about being able to override what a given literal is turned into. It would only take effect in a limited scope, either per module, per compile