Re: Subclassing built-in classes

2006-10-10 Thread Theerasak Photha
On 10/9/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > At Saturday 7/10/2006 04:35, hanumizzle wrote: > > > > >As the first post said "...couldn't python (in theory)...", I > > was discussing > > > >if it would be possible for python (in some future version) to manage the > > > >literals so tha

Re: Subclassing built-in classes

2006-10-09 Thread Gabriel Genellina
At Saturday 7/10/2006 04:35, hanumizzle wrote: > >As the first post said "...couldn't python (in theory)...", I was discussing > >if it would be possible for python (in some future version) to manage the > >literals so that they use the constructors in the __builtin__ module, I > >didn't say it

Re: Subclassing built-in classes

2006-10-07 Thread hanumizzle
On 10/7/06, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > At Friday 6/10/2006 06:58, Maric Michaud wrote: > > >As the first post said "...couldn't python (in theory)...", I was discussing > >if it would be possible for python (in some future version) to manage the > >literals so that they use the

Re: Subclassing built-in classes

2006-10-07 Thread Gabriel Genellina
At Friday 6/10/2006 06:58, Maric Michaud wrote: As the first post said "...couldn't python (in theory)...", I was discussing if it would be possible for python (in some future version) to manage the literals so that they use the constructors in the __builtin__ module, I didn't say it works actua

Re: Subclassing built-in classes

2006-10-06 Thread MonkeeSage
On Oct 6, 4:58 am, Maric Michaud <[EMAIL PROTECTED]> wrote: > As the first post said "...couldn't python (in theory)...", I was discussing > if it would be possible for python (in some future version) to manage the > literals so that they use the constructors in the __builtin__ module, I > didn't

Re: Subclassing built-in classes

2006-10-06 Thread Maric Michaud
Le jeudi 05 octobre 2006 20:24, Steve Holden a écrit : >   >>> class mystr(oldstr): >   ...   def __new__(*a, **kw): >   ...     print "called:", a, kw >   ... you don't return the string here... >   >>> import __builtin__ >   >>> __builtin__.str = mystr >   >>> > Readline internal error > Traceb

Re: Subclassing built-in classes

2006-10-05 Thread Steve Holden
Maric Michaud wrote: > Le jeudi 05 octobre 2006 15:52, Steve Holden a écrit : > >>>But what prevents to interpret literals as a call to __builtins__ objects >>>and functions ? optimization ? what else ? >> >> >>When are literals interpreted? During translation into bytecode. > > > agreed, but wh

Re: Subclassing built-in classes

2006-10-05 Thread Maric Michaud
Le jeudi 05 octobre 2006 15:52, Steve Holden a écrit : > > But what prevents to interpret literals as a call to __builtins__ objects > > and functions ? optimization ? what else ? > > > When are literals interpreted? During translation into bytecode. agreed, but what's the problem with this ? We

Re: Subclassing built-in classes

2006-10-05 Thread Steve Holden
Maric Michaud wrote: > Le jeudi 05 octobre 2006 14:20, Steve Holden a écrit : > >>Unfortunately the literals are interpreted during bytecode generation, >>before the compiled program is available, and your modifications to >>__builtns__ haven't been made, so the answer is "no", I'm afraid. > > >

Re: Subclassing built-in classes

2006-10-05 Thread Maric Michaud
Le jeudi 05 octobre 2006 14:20, Steve Holden a écrit : > Unfortunately the literals are interpreted during bytecode generation, > before the compiled program is available, and your modifications to > __builtns__ haven't been made, so the answer is "no", I'm afraid. But what prevents to interpret l

Re: Subclassing built-in classes

2006-10-05 Thread MonkeeSage
Steve Holden wrote: > Unfortunately the literals are interpreted during bytecode generation, > before the compiled program is available, and your modifications to > __builtns__ haven't been made, so the answer is "no", I'm afraid. Ah! That makes sense. I guess the only way to do it would be to add

Re: Subclassing built-in classes

2006-10-05 Thread Steve Holden
MonkeeSage wrote: > I know that python doesn't allow extending built-in objects like the > str class; but you can subclass them using a class of the same name and > thus shadow them to get the same general effect (albeit you have to use > the explicit constructor rather than literals). > > class s

Subclassing built-in classes

2006-10-05 Thread MonkeeSage
I know that python doesn't allow extending built-in objects like the str class; but you can subclass them using a class of the same name and thus shadow them to get the same general effect (albeit you have to use the explicit constructor rather than literals). class str(str): def display(self):