Steven D'Aprano <st...@pearwood.info>: > On Wed, 30 Mar 2016 10:21 pm, Jussi Piitulainen wrote: >> Ok, safer to say that some many-to-one mappings are not surjective. > > Can you give an example of a Python dict which is not surjective?
Depends on the codomain. The values() method gives the range. If you have an ordinary Python dictionary that maps strings to strings, it will be neither total nor surjective. Since there are strings that are not among the keys (not total) and there are strings that are not among the values (not surjective). You can of course equate keys() with the domain and values() with the range, in which case the whole discussion becomes nonsensical. However, a collections.defaultdict instance can be both total and surjective in the meaningful senses of the words. Marko -- https://mail.python.org/mailman/listinfo/python-list