On Mon, Sep 20, 2010 at 12:04 PM, Emile van Sebille <[email protected]> wrote:
> On 9/20/2010 7:16 AM Michael Scharf said... > > Why is it >> list0.extend(list1) >> and not >> extend(list 0, list1) >> or >> stri0 = stri0.strip() >> and not >> stri0 = strip(stri0) >> Why have arguments on the left side at all, when usually the dot notation >> left to right implies a hierarchical relation: file.class or class.method >> etc. >> >> > You can also have it your way... > > >>> def extend(*args): > ... try: > ... args[0].extend(*args[1:]) > ... except: > ... raise AttributeError > ... > >>> > ... > >>> > >>> a = [] > >>> a.extend([1,2,3]) > >>> a > [1, 2, 3] > >>> extend(a,[4,5,6]) > >>> a > [1, 2, 3, 4, 5, 6] > >>> > > > Emile > > That's pretty creative I think, but not sure its quite on the mark for beginners? ;) Anyway, I was quick with my answer. This is a good place to learn about list and string methods: http://docs.python.org/library/stdtypes.html#built-in-types > > > _______________________________________________ > Tutor maillist - [email protected] > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > -- Joel Goldstick
_______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
