Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'that?': 0.05; 'behave': 0.09; 'dict': 0.09; 'def': 0.10; '__getitem__,': 0.16; '__len__,': 0.16; 'len(c)': 0.16; 'subject:class': 0.16; 'thanks,': 0.18; 'define': 0.20; 'pass': 0.25; 'message-id:@mail.gmail.com': 0.27; 'skip:_ 10': 0.29; 'class': 0.29; 'could': 0.32; 'print': 0.32; 'received:74.125.82': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'received:74.125': 0.36; 'should': 0.36; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'more': 0.63; 'florian': 0.84; 'subject:Using': 0.84; 'do:': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xgm.de; s=google; h=mime-version:x-received:sender:x-google-sender-delegation :x-originating-ip:date:x-google-sender-auth:message-id:subject:from :to:content-type; bh=tzSuqm34+mUkxM9pP+oGnzeGQfBk6KcBFq5yShANAoY=; b=Mmxplg4B076qvo7TFob2YPNlhTvdTZGnUhP8GAedgfBaDm77Okzrto82lCUWnL078J QSXzsKWvwv2GZEo8ql0tK6D/EtVD06I0Tsns3epBzBqzabMhfeQyon8K1ky/MHuDIWLP QB9c5e9CUNqwxX9TgFVgciKsEqpfxqgeSe6+U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:x-google-sender-delegation :x-originating-ip:date:x-google-sender-auth:message-id:subject:from :to:content-type:x-gm-message-state; bh=tzSuqm34+mUkxM9pP+oGnzeGQfBk6KcBFq5yShANAoY=; b=e9mbSEL9Vl2btXuAnABF1RYUTVpsde+gOf4PL8HP/2H+bRlM2N+GIog+OalZhLOqWU zWeqN8LlfSWtl0gRKWGKeigfGHjKxNsHobVBU9Oga86UYnPVvHQm3zMuDuTzn5M8NTWd 80L5CP8I6Zfn+I89txyE1S+/HNlmro1C4Z3ZApE8fpeUyMQPzkoiXde/vSXAERFOn+l9 5eYWdOYPf0yPsnae6ZqFr4Ti892rtBLOgg4tnkcwZmKOzuiyMlxpctGjxUHhkhBV9gTS 5TSGp0qrxE3LBvVnr7fHlw4bdcm3z22hWkYaRnGQE0jZ9K8b/THVNUegsDbipM2iXCot jvOg== MIME-Version: 1.0 X-Received: by 10.194.76.165 with SMTP id l5mr2727927wjw.14.1358347362649; Wed, 16 Jan 2013 06:42:42 -0800 (PST) Sender: florian.lindner@xgm.de X-Google-Sender-Delegation: florian.lindner@xgm.de X-Originating-IP: [129.187.68.60] Date: Wed, 16 Jan 2013 15:42:42 +0100 X-Google-Sender-Auth: AJLD28QsyJO-BvmdX7oggqrSupc Subject: Using inner dict as class interface From: Florian Lindner To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkst7sVCXl7lNqAepzfGdqohEHOdc7SfcZRhL44JCFPqlMYuHU+/Ui+P513/rywHa2zgVFn X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358347369 news.xs4all.nl 6867 [2001:888:2000:d::a6]:49872 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36897 Hello, I have a: class C: def __init__(self): d = dict_like_object_created_somewhere_else() def some_other_methods(self): pass class C should behave like a it was the dict d. So I could do: c = C() print c["key"] print len(c) but also c.some_other_method() How can I achieve that? Do I need to define all methods like __getitem__, __len__, ... (what else?) to access the inner dict or is there something more slick? Thanks, Florian