Re: Why don't stringobjects have methods?

Steven D. Majewski (sdm7g@elvis.med.virginia.edu)
Fri, 1 Apr 1994 18:31:24 -0500

On Apr 1, 17:36, Tim Peters wrote:
> [jim]
> > ...
> > Finally, the *real* reason why I entered this thread is to push for
> > being able to write the equivalent of:
> >
> > for i in foo.keys().sort():
> > ...
>
> Unless you're addicted to dangling-method _syntax_, it's easy to write
> your own sort _function_ to do this. E.g, the following works fine
> today:
>
> def sort(sequence):
> sequence.sort() # precede by "sequence = sequence[:]" for a copying sort
> return sequence
>
> for i in sort(foo.keys()):
> ...
>
> So does the obvious:
>

for x in sequence.sort() or sequence :
print x

However, I sort of like the idea of distinguishing between a
sort METHOD, which returns None, and has a side effect on it's
object, a sort procedure function that returns the sorted object,
and a sort FUNCTION function that returns a sorted copy of the
sequence.

I often find myself clashing with Guido over programming
style/paradigms/idioms, however, Python is so mallable,
it is hard to get TOO worked up over it.

The only problem in this relates to Jack's post about
orgainzing libraries: If you add a lot of customized
defaults to Python, then you have to remember to
distribute all of the dependencies along with you
modules. ( "Oops. Sorry - that all assumes your
PYTHONDEFAULT loads my set of 'standard' utility
modules first!" :-)

Since Guido has his hands full just maintaining Python
( in between his own work ) I suppose eventually "we"
will need to "take over" maintaining the Python
Library - Or *A* Python Library that is somewhat
larger than the distribution library - or at least
some subset of it.

( I won't get into defining who "we" might be - I can
hear everyone heading for the exits RIGHT NOW!! :-)

- Steve Majewski (804-982-0831) <sdm7g@Virginia.EDU>
- UVA Department of Molecular Physiology and Biological Physics