list to tuple and vice versa

Ben Finney ben+python at benfinney.id.au
Sun Oct 18 01:32:53 EDT 2009


StarWing <weasley_wx at sina.com> writes:

> On 10月18日, 下午12时19分, Ben Finney <ben+pyt... at benfinney.id.au> wrote:
> > Jabba Laci <jabba.l... at gmail.com> writes:
> > > Right, it was my bad. After removal the tuple() function works
> > > perfectly.
> >
> > Note that, though it is callable, ‘tuple’ is not a function but a
> > type:
>
> A type is always callable.

Yes (modulo perversions like explicitly making a non-callable type).
This matches what I said above.

> call a type will call its __init__ special method (or and __new__
> special method together).

No <URL:http://docs.python.org/reference/datamodel.html#object.__new__>
<URL:http://docs.python.org/reference/datamodel.html#object.__init__>.

-- 
 \      “Anyone who believes exponential growth can go on forever in a |
  `\        finite world is either a madman or an economist.” —Kenneth |
_o__)                                                         Boulding |
Ben Finney



More information about the Python-list mailing list