a strange question in it.comp.lang...
holger krekel
pyth at devel.trillke.net
Wed Jan 8 14:17:05 EST 2003
6e6op wrote:
> this is (more or less) the translation
>
> From: "Matteo Bertini" <m.bertini at tin.it>
> Newsgroups: it.comp.lang
> Sent: Sunday, January 05, 2003 11:26 PM
> Subject: [PYTHON] estendere tipi di base
>
>
> > I can build a class in this way:
> >
> > class mystring(str):
> > def is_email(self):
> > return self.find("@")
> >
> > use it in:
> >
> > mystring("pippo at pippo.it").is_email()
> >
> > the answer is, can i define mystring to be the default string class?
> > can i ''validate'' "pippo".is_email() ?
> > maybe is not goot, but is only curiosity.
> >
> > thanks,
> > Matteo
>
> ok, then one answer jump in my brain:
> there's a "place" where the interpreter load the __builtins__ package?
> obviously __builtins__.str cannot be substitute with a customized one after
> the __builtins__ load ,
> but before load?
This wouldn't help (and you probably mean __builtin__, btw.).
The construction of a string object doesn't involve a lookup
of the builtin namespace. 'str' is just a convenient (builtin)
way to get to the string type.
> if the interpreter load __builtins__ in some place i can translate
> __builtins__.str
> with a __builtins__.mystr before that interpreter load __builtins__
>
> is it possible?
no.
cheers,
holger
More information about the Python-list
mailing list