Re: __init__ function problem

2006-11-07 Thread babui

Steven D'Aprano ha escrit:

> Once the __new__ method creates the instance and returns, before anything
> else happens, the instance's __init__ method is called.

This only happens when the object created by __new__ isinstance of the
class invoked in the creation statement, that is:

s=MagicStr("lala")

executes:

s = MagicStr.__new__(MagicStr, "lala")
if isinstance(s, MagicStr):
type(s).__init__(s, "lala")

--
Juan M. Gimeno

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting a list depending of the indexes of another sorted list

2008-01-20 Thread babui
On 21 ene, 08:41, Santiago  Romero <[EMAIL PROTECTED]> wrote:
>  Hi ...
>
>  I have the following DNS MX records info:
>
> domain.com
> preference 10 host mx1.domain.com
> preference 30 host anotherhost.domain.com
> preference 20 host mx2.domain.com

>  And finally ... do you think there is a better python structure to
> store this data and sort it in a more easy way?

Why don't you use a list of tuples?

L = [ (10, "mx1.domain.com"), (30, "anotherhost.domain.com", (20,
"mx2.domain.com") ]

and L.sort() sorts the list !!!

Juan M. Gimeno
>  Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list