On 28 June 2010 00:27, Steven D'Aprano <st...@pearwood.info> wrote: > On Mon, 28 Jun 2010 03:12:39 am Adam Bark wrote: > > > I think the 'as' syntax is only available in Python 3.x > > You think wrong. It is available from Python 2.6 onwards. >
I know, I corrected myself after Steve Willoughby pointed it out. > > > > Question marks go at the end of the sentence where you would normally > > put a full stop if it wasn't a question. > > That's a terribly unhelpful answer given the context of Payal's > question. I'm sure he knows the grammatical rules for questions in > ordinary English sentences, but he's asking specifically about a > particular form of sentence where you have a question consisting of two > or more alternatives or examples separated as paragraphs: > > Well it was a terribly unclear question, I just answered what I thought he was asking. > [example] > Hello, which is better, a lambda: > > (1) lambda x: x+1 > > or a function definition: > > (2) def f(x): > return x+1? > [end example] > > It is very reasonable to ask where to put the question mark in examples > like this. Unfortunately there is no good answer. If you put it on the > same line as the second example, as shown, certainly isn't correct > because it makes the question mark part of the example. It's > *especially* dangerous in a programming context, because it leads to a > syntax error. > > Putting it on a line on it's own after the example looks silly. > Re-writing the question to avoid the problem is often awkward, but can > be done: > > [rewritten example] > Hello, which of these two are better? > > (1) lambda x: x+1 > > (2) def f(x): > return x+1 > [end rewritten example] > > Since there is no One Right Answer, you can do whichever seems best in > context. > I'm sure this "work it out yourself" answer is much more helpful.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor