Python 3K or Python 2.9?

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Sep 12 23:57:56 EDT 2007


TheFlyingDutchman <zzbbaadd at aol.com> writes:

(Please, preserve attribution lines so it's clear who wrote what in
your quoted material.)

> >     >>> Foo.bar(foo, "spam")
> >     >>> foo.bar("spam")
> 
> That looks like a case of "There's more than one way to do it". ;)

Indeed, but there's only one *obvious* way to do it. (The latter, in
this case.)

> The first form is definitely consistent with the method declaration,
> so there's a lot to be said for using that style when teaching
> people to make classes -> send self, receive self.

Sure, go ahead and teach that way if you like; it'll work fine.

> 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"?

Specifically an easier way of doing it provided by the language syntax
(hence "syntactic sugar"). As in, "the form 'foo += 1' is syntactic
sugar for 'foo = foo + 1'".

-- 
 \      "I don't know half of you half as well as I should like, and I |
  `\      like less than half of you half as well as you deserve."  -- |
_o__)                                                    Bilbo Baggins |
Ben Finney



More information about the Python-list mailing list