On 22/06/13 17:56, Sivaram Neelakantan wrote:

list.append(b.get('a'),'c')


Lets look at what this is doing in simplistic terms.

'list' is the class and 'append' is a method of the class.
When we call a method via the class we have to provide the 'self' argument explicitly so in this case self is

b.get('a')

which is the result of getting the value associated with the key 'a'; in b.

or put another way it is b['a']

so we can simplify a little to

list.append(b['a'], 'c')

But we normally call methods via the object instance rather than the class so simplifying this further we get:

b['a'].append('c')

Which is how we would normally do it.

HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to