dictionary inherit and method overriding

fdb fabiodib at email.it
Wed Jul 15 08:19:15 EDT 2009


Only this! I'm going crazy!

Than you!

Code:


class myDict(dict):
    def __getitem__(self, y):
        print("Doing something")
        return dict.__getitem__(self, y)

a=myDict()
a["value"] = 1
print a["value"]


Christian Heimes ha scritto:
> How about returning the value? :]


-- 
FabioBD




More information about the Python-list mailing list