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/2001-May/015008.html below:

[Python-Dev] strop vs. string

[Python-Dev] strop vs. stringGreg Stein gstein@lyra.org
Thu, 24 May 2001 06:00:16 -0700
On Thu, May 24, 2001 at 12:18:50PM +0200, M.-A. Lemburg wrote:
> Greg Stein wrote:
>...
> > So... my question is: is there any way that we can retain a generic find()
> > (and similar functions from the string/strop module) that operates on any
> > type that implements the buffer API?
> > 
> > Maybe there is some way we can do a mixin for Python types? e.g. "this mixin
> > implements some standard methods for 8-bit character data (using the buffer
> > API), which can be mixed into new Python types" That would reduce the burden
> > for new types.
> 
> I suppose that in 2.2 we'll be able to build a class/type
> hierarchy which then provides these possibilities. I haven't
> followed Guido's latest checkins closely though -- could be that
> types don't support multiple inheritence.

No idea either... that's why I asked.

> BTW, wouldn't it suffice to add these methods to buffer objects ?
> Then you could write: buffer(ob).find('.').

You're totally missing the point with that suggestion. It does *not* suffice
to add them to buffer objects. What about array objects? mmap objects?
Random Joe Object who implements the buffer interface?

All of those are out of luck.

With strop, I can pass any of those objects to strop.find(). That function
has a polymorphic argument.

In the current arrangement, every object must implement their own .find and
.upper and .whatever.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/



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