Ben Finney writes:
 > Steven D'Aprano <st...@pearwood.info> writes:

 > > "get" is such a generic term that I don't believe that is a problem.
 > 
 > The problem above is made less problematic by the fact that the function
 > signature (e.g. 'foo_dict.get(key)') clarifies the answer to the
 > question "get what?". Whereas 'foo_set.get()' doesn't communicate much
 > at all to the reader.

I agree.

This is precisely why a couple of months ago people were proposing
names like ".getany()" for this API.

The problem brought up then was that pretty clearly people would then
do things like

    x = foo.getany()
    y = foo.getany()

expecting x and y to be different (ie, interpreting "any" as "random").
Pretty soon there was a whole family of proposals for such methods:
.getfirst(), .getlast(), .getrandom(), .getonly(), ....

I think it would be better to document the various ways of doing this,
and let each program define its own oneliner for the MySet.get() that
makes idiomatic sense in its use case.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to