[Tutor] adding methods to native types

Sean 'Shaleh' Perry shalehperry@attbi.com
Wed Feb 5 23:22:15 2003


On Wednesday 05 February 2003 20:07, Don Arnold wrote:

>
> Lists already have a builtin magical method for this (which is what the=
 len
> function calls to get its value):
>
> Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
> Type "copyright", "credits" or "license" for more information.
> IDLE 0.8 -- press F1 for help
>
> >>> a =3D [1,2,3,4,5]
> >>> a.__len__()
>
> 5
>

true.  However "magic" methods are just that and should not be used in ca=
sual=20
code.