On Tue, Nov 29, 2011 at 9:54 AM, Cranky Frankie <cranky.fran...@gmail.com>wrote:
> Peter Otten <__pete...@web.de> wrote: > > <snip> Isn't msg_widget an object, like everything else in Python. If so, why is > it not > > def display_quote(): > msg_widget.text = choose_quote() > > That is one of the things I tried. I don't understand why the ["test"] > pair works above. > Just because msg_widget is an object doesn't automatically give it a .text attribute. Just like the following dictionary (which is an object): >>> knights = {'Aurthur': 'King of the Britons', 'Robin':'The Brave'} >>> knights['Robin'] 'The Brave' >>> knights['Robin'] = 'The Coward' >>> knights.Robin Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'dict' object has no attribute 'Robin' They simply made a design choice to allow access to the data via index (in this case "text" is the index), rather than by object attribute. HTH, Wayne
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor