Greg Stein wrote: > > 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? That's the point: you can wrap all those into a buffer object and then use the buffer object methods to manipulate them. In that sense, buffer objects provide an adaptor to the underlying object which implements the needed methods. > 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/ -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/
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