Python 3K or Python 2.9?

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Sep 13 03:41:17 EDT 2007


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.



More information about the Python-list mailing list