Order in metaclass

Peter Otten __peter__ at web.de
Thu Oct 14 04:11:37 EDT 2004


Carlos Ribeiro wrote:

> if not isinstance(value, self.mytype):
>     # if it's a string, tries to convert to the correct
>     # target type (this is needed because most things read
>     # from files will be strings anyway)
>     if isinstance(value, StringType):
>         value = self.mytype(value)

I haven't checked if this is relevant in the context, but implicit
conversion from string is usually a bad thing. E. g.:

>>> bool("False"), bool("0")
(True, True)

Peter




More information about the Python-list mailing list