TheFlyingDutchman a écrit : >> >>> Foo.bar(foo, "spam") >> >>> foo.bar("spam") > > That looks like a case of "There's more than one way to do it". ;)
Nope, on the contrary. The nice thing with this model is that you don't have distinct rules for functions and methods, since methods are just plain functions. >> The latter two statements are equivalent. The 'instance.method(args)' >> syntax is just sugar for 'Class.method(instance, args)'. > > I think I saw where Guido Van Rossum had referred to something as > "syntactic sugar" in some python.org page. I am not familiar with > sugar as related to syntax. Is it being used as a synonym for "easier > way of doing it"? Yes. "syntactic sugar" mostly means "nicer, simpler syntax for something that could be done without". And one of the *great* strength of Python is that it exposes both the syntactic sugar for the most common uses case and the underlying implementation for most advanced tricks. -- http://mail.python.org/mailman/listinfo/python-list