Subclassing built-in classes
Maric Michaud
maric at aristote.info
Fri Oct 6 05:58:21 EDT 2006
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
> Traceback (most recent call last):
> File "C:\Python24\lib\site-packages\readline\Console.py", line 644,
> in hook_wrapper_23
> raise TypeError, 'readline must return a string.'
...It should explain this error.
>
> So, what are you trying to say? The type of the literal strings is
> clearly just what it always was. Where, when and how exactly does this
> magical monkey patch affect literals?
ooops, maybe we aren't on the same plan.
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 actually (I'm aware it's not the case).
--
_____________
Maric Michaud
_____________
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
More information about the Python-list
mailing list