A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-May/024817.html below:

[Python-Dev] Removing types module from stdlib

[Python-Dev] Removing types module from stdlibGuido van Rossum guido@python.org
Fri, 31 May 2002 15:42:43 -0400
> I use this little toy on occasion:
> 
> class istr(str):
>   __slots__ = ()
>   def __hash__(self):
>     return hash(self.lower())
>   def __eq__(self, other):
>     return self.lower() == other.lower()
>   def __ne__(self, other):
>     return self.lower() != other.lower()
>   def __le__(self, other):
>     return self.lower() <= other.lower()
>   def __ge__(self, other):
>     return self.lower() >= other.lower()
>   def __lt__(self, other):
>     return self.lower() < other.lower()
>   def __gt__(self, other):
>     return self.lower() > other.lower()
> 
> Are you saying that you want to outlaw it?

No, subclassing str (or unicode) is fine, because then you inherit the
implementation properties.

I want to outlaw (or at least discourage) creating new subclasses of
the basestring type (in current CVS it's called string, but it will be
renamed soon).

If someone writes isinstance(x, basestring) they should be confident
that x is either a str, a unicode, an instance of a subclass of those,
or something written in C that works real hard to look like a string.

--Guido van Rossum (home page: http://www.python.org/~guido/)




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4