A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/070854.html below:

Unbound methods of types

Unbound methods of typesChristian Tanzer tanzer at swing.co.at
Mon Apr 30 04:11:59 EDT 2001
Ben Hutchings <ben.hutchings at roundpoint.com> wrote:

> Let me try to explain myself more clearly.  If strings were instances
> of a class String, I could say String.foo to get the unbound string
> method foo; as it is, there happens to be a string module so I can say
> string.foo to get a function that works as if it were the unbound
> string method (except where foo = join).  For other sequences such as
> lists, there is no such module to help.  To pick a better example, I
> can't say:
> 
>     map(types.DictType.keys, [{'a':1,'b':2,'c':3}, {'d':4,'e':5,'f':6}])
> 
> and get back something like:
> 
>     [['b', 'c', 'a'], ['f', 'd', 'e']]

Doing this is a bad idea. If you map an unbound method, any
polymorphism is lost (e.g., a UserDict instance in the list passed to
map would not work). 

-- 
Christian Tanzer                                         tanzer at swing.co.at
Glasauergasse 32                                       Tel: +43 1 876 62 36
A-1130 Vienna, Austria                                 Fax: +43 1 877 66 92



More information about the Python-list mailing list

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