On 21/01/16 03:42, boB Stepp wrote: > So I really only have one question: Why not make Python's > *traditional* name, "self", mandatory? Why give the programmer this > kind of choice? [OK, that was two questions.]
Because to do otherwise would introduce all sorts of extra complexity into the standard function calling mechanism. There is nothing super special about methods they are just functions. You can call the parameters of a function anything you like. To suddenly have the interpreter check the name of the first positional parameter for the specific case of a method makes no sense. And it's very convenient to allow other names. When I'm playing at the >>> prompt I often just substitute s for self to save typing. When sharing Python code with C++ or Java programmers I often use 'this' instead because they will understand that. Python gives us flexibility which we are expected to use responsibly. It's a good thing. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor